Wednesday, March 7, 2012

Error connecting to DB

Hi everyone,

I am learning how to use .NET and MSDE. I am working out of the book "ASP.NET Unleashed" on the Job Site (Chap 30)

I have used osql to run the .sql script, but now I am having problems connecting to the DB; I get "SQL Server does not exist or access denied"

The web.config file is:

<configuration>
<appSettings>
<add key="constring"
value="Server=localhost;UID=AspNETJobsUser;PWD=secret;Database=AspNetJobs" />
</appSettings>
<system.web>
<authentication mode="Forms" >
<forms name=".ASPNETJOBS"
loginUrl="/aspnetjobs/site/password/login.aspx" />
</authentication>
</system.web>
</configuration
My computer is running in Windows Authentication Mode.

I have tried replacing the UID and PWD to my sa account settings, but I still can not connect.
The books says I need to manually add a login that has access to the AspNETJobsDatabase, but I assume that would be the sa login or do I need to create another all together? If so, can anyone suggest an article to lead me in that direction.

Any suggestions would be helpful and greatly appreciated.

ThanksHere's an article that'll tell you how to add a login to an MSDE instance.

Regards,

Xander|||Data Source=IpAddyorServerName;Initial Catalog=DbName;User ID=UserName;Password=BlankpasswordSucks|||[SqlException: Impossibile eseguire l'accesso per l'utente 'sa'. Motivo: l'utente non è associato a una connessione SQL Server trusted.]

Why?
Bye Bye!|||I changed my code in the Web.config file to:

<configuration>
<appSettings>
<add key="constring"
value="Data Source=SHAYLA1;Initial Catalog=AspNetJobs;User ID=AspNETJobsUser;Password=secret" />
</appSettings>
<system.web>
<authentication mode="Forms" >
<forms name=".ASPNETJOBS"
loginUrl="/aspnetjobs/site/password/login.aspx" />
</authentication>
</system.web>
</configuration
and now I get the error:
Login failed for user 'AspNETJobsUser'. Reason: Not associated with a trusted SQL Server connection.

I followed the article on how to create a login, and I got the message of "user AspNETJobsUser already exists"

When I change the User to sa and password to "my password," I still get the same error

Still missing something?|||just an update for anybody out there that might be facing the same problem. I changed the setting to Mixed Mode from Windows authentication following the direction of the article at

http://support.microsoft.com/?kbid=322336#2

Once I restarted my computer, the app came up fine.

My final web.config files looks like so:

<configuration>
<appSettings>
<add key="constring"
value="Server=(local);Database=AspNetJobs;UID=AspNETJobsUser;PWD=secret" />
</appSettings>
<system.web>
<authentication mode="Forms" >
<forms name=".ASPNETJOBS"
loginUrl="/aspnetjobs/site/password/login.aspx" />
</authentication>
</system.web>
</configuration
Thank you to those who responded to my original post.

No comments:

Post a Comment