The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

import-bot (20211) [Avatar] Offline
#1
[Originally posted by chriskeith]

I've gotten to Ch. 8, and am getting strange behavior from the hello.aspx
page. The first time I point to it from the browser, I get an error. Every
succeeding time, it runs fine. I can reproduce it by rebooting and running
the page again. Anyone have any clues? I don't understand why there should be
any database interaction. - Thanks, Chris

---------text of
Server Error in '/cha_8' Application.
--------------------------------------------------------------------------------

Cannot open database requested in login 'poker'. Login fails. Login failed for
user 'MOEASPNET'.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Cannot open database
requested in login 'poker'. Login fails. Login failed for user 'MOEASPNET'.

Source Error:

The source code that generated this unhandled exception can only be shown when
compiled in debug mode. To enable this, please follow one of the below steps,
then request the URL:

1. Add a "Debug=true" directive at the top of the file that generated the
error. Example:

<%@ Page Language="C#" Debug="true" %>

or:

2) Add the following section to the configuration file of your application:

<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
</configuration>

Note that this second technique will cause all files within a given
application to be compiled in debug mode. The first technique will cause only
that particular file to be compiled in debug mode.

Important: Running applications in debug mode does incur a memory/performance
overhead. You should make sure that an application has debugging disabled
before deploying into production scenario.

Stack Trace:

[SqlException: Cannot open database requested in login 'poker'. Login fails.
Login failed for user 'MOEASPNET'.]
System.Data.SqlClient.SqlConnection.Open() +761
System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection,
ConnectionState& originalState) +44
System.Data.Common.DbDataAdapter.Fill(Object data, Int32 startRecord, Int32
maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +98
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord,
Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior
behavior) +77
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +36
ASP.global_asax.Application_Start(Object sender, EventArgs e) +107
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.0.3705.0; ASP.NET
Version:1.0.3705.0
import-bot (20211) [Avatar] Offline
#2
Re: Database (?) error in hello.aspx
[Originally posted by fgrimes]

Hi Chris,

You got me there! Truly bizarre since all the example does is say "hello".
Check your setup and try some other aspx apps.

Fergal
import-bot (20211) [Avatar] Offline
#3
Re: Database (?) error in hello.aspx
[Originally posted by chriskeith]

Figured it out. I needed to give my local machine the access rights to the
Poker database (apologies for bad linebreaks or disappearing backslashes):

osql -E -S (local)NetSDK -d Poker -Q "sp_grantdbaccess 'MACHINENAMEASPNET'"
osql -E -S (local)NetSDK -d Poker -Q "sp_addrolemember 'db_owner',
'MACHINENAMEASPNET'"

Got a clue when the datagrid example (datagrid.aspx) absolutely refused to
run. Went back and reviewed the MSDE ConfigDetails.htm document. Don't know
why the hello.aspx example wants to get to the the database, but there you
are.

- Chris
import-bot (20211) [Avatar] Offline
#4
Re: Database (?) error in hello.aspx
[Originally posted by fgrimes]

Glad you got to the bottom of it.
FG
msvm (1) [Avatar] Offline
#5
Re: Database (?) error in hello.aspx
Hi,

That was exactly what I was looking for but it didn't work.

I got the following error:

[DBMSLPCN]SQL Server does not exist or access denied.
[DBMSLPCN]ConnectionOpen (Connect()).


Any ideas?

Thanks a lot in advance,

Marta