The error I get is that it can't login using the login details provided
Just wondering if there's anything I'm not doing something properly? This is the first time I'm trying to connect to a database using Windows 7/SQL Server Express so hoping someone with a bit more experience can give me a hand!
My guess is that when you are using Windows Authentication, you have not setup the ASPNET worker account to have permissions. Windows Authentication only uses the ASPNET worker process account identity unless you turn on impersonation - then it uses YOUR
account (or the account of whoever is logging in).
Darrell Norton, MVP
Darrell Norton's Blog Please click "Mark as Answer" if this helped you.
I agree with @DarrellNorton. You have to provide the actual error in order to provide you support for your issue. There might be number of reasons why you can't connect to SQL Server (Express) from your application.
IT seems like your connection sting is not valid. Correct the server name from
".\\SQLEXPRESS" to ".\SQLEXPRESS" .
Hope it helps.
If he changes the connection string on that way, he will get Unrecognize escape sequence error. The double
back-slashes are used to escape this error. Otherwise, if he writes the connection string on your way, the
@ in the beginning of the string will be required to avoid this error ;).
Best Regards,
Hajan
Dont forget to Mark as Answer the answer that solved your problem!
you can create a connection to your database using Server Explorer in IDE. And when you successfull create a connection to your database then just right click your connection in server explorer and click properties option. Now in properties you will g et
a connection string which will 100% help you.
MagSafe
Member
1 Points
8 Posts
Connect to SQL Server Express using ASP.NET
Jul 27, 2010 10:01 AM|LINK
Hey,
I'm a bit of a beginner to ASP.NET and I'm having a trouble connecting to SQL Server Express.
I'm using Windows 7 and have tried connecting to my database using both Windows authentication and a user account I setup in SQL Server.
I've include the code I'm using below (using the account I setup in SQL Server):
The error I get is that it can't login using the login details provided
Just wondering if there's anything I'm not doing something properly? This is the first time I'm trying to connect to a database using Windows 7/SQL Server Express so hoping someone with a bit more experience can give me a hand!
Thanks :)
SQL 2008 Windows 7 ASP IIS7
DarrellNorto...
All-Star
87441 Points
9717 Posts
Moderator
MVP
Re: Connect to SQL Server Express using ASP.NET
Jul 27, 2010 10:51 AM|LINK
Post the exact error.
My guess is that when you are using Windows Authentication, you have not setup the ASPNET worker account to have permissions. Windows Authentication only uses the ASPNET worker process account identity unless you turn on impersonation - then it uses YOUR account (or the account of whoever is logging in).
Darrell Norton's Blog
Please click "Mark as Answer" if this helped you.
vik20000in
All-Star
25882 Points
3993 Posts
MVP
Re: Connect to SQL Server Express using ASP.NET
Jul 27, 2010 10:54 AM|LINK
check the below link for connection string problem
http://www.connectionstrings.com/sql-server-2005
www.vikramlakhotia.com
Please mark the answer if it helped you
eralper
Contributor
6048 Points
971 Posts
Re: Connect to SQL Server Express using ASP.NET
Jul 27, 2010 10:54 AM|LINK
I can suggest you to use SqlConnectionStringBuilder class while creating sqlconnection object. And try using Data Source instead of Server.
SqlConnection objConn = new SqlConnection( "Data Source=servername\SQLEXPRESS;" + "Initial Catalog=dbDorknozzle;" + "User ID=userDorknozzle; Password=passDorknozzle");While setting the instance name use servername\instance name syntax not .\\SQLExpress
sqllconnection sqlconnectionstringbuilder
SQL Server 2012
hajan
Star
10655 Points
1782 Posts
Re: Connect to SQL Server Express using ASP.NET
Jul 27, 2010 10:57 AM|LINK
I agree with @DarrellNorton. You have to provide the actual error in order to provide you support for your issue. There might be number of reasons why you can't connect to SQL Server (Express) from your application.
To start by understanding the most common things you need to know, pass through the following article: http://www.teratrax.com/articles/connecting_sql_server_express.html
For more help, please reply with more details.
Hajan
Dont forget to Mark as Answer the answer that solved your problem!
My ASP.NET Weblog
prathamjain2...
Member
743 Points
569 Posts
Re: Connect to SQL Server Express using ASP.NET
Jul 27, 2010 11:00 AM|LINK
Hiii,
try this:
windows authentication:
connectionstring="datasource=servername;InitialCatalog=db_name;Integrated Security=true"
providername="System.Data.SqlClient"
sql authentication:
connectionstring="datasource=servername;InitialCatalog=db_name;Persist Security Info=true;Uid=sql_userid;Password=passwd"
providername="System.Data.SqlClient"
Plz rep if there is some other issue
Please mark as answer if this post helps u
sunilyadav16...
Participant
1955 Points
370 Posts
Re: Connect to SQL Server Express using ASP.NET
Jul 27, 2010 11:05 AM|LINK
Hi,
IT seems like your connection sting is not valid. Correct the server name from ".\\SQLEXPRESS" to ".\SQLEXPRESS" .
Hope it helps.
Follow me here
hajan
Star
10655 Points
1782 Posts
Re: Connect to SQL Server Express using ASP.NET
Jul 27, 2010 11:51 AM|LINK
If he changes the connection string on that way, he will get Unrecognize escape sequence error. The double back-slashes are used to escape this error. Otherwise, if he writes the connection string on your way, the @ in the beginning of the string will be required to avoid this error ;).
Hajan
Dont forget to Mark as Answer the answer that solved your problem!
My ASP.NET Weblog
nkd1083
Member
397 Points
298 Posts
Re: Connect to SQL Server Express using ASP.NET
Jul 27, 2010 01:12 PM|LINK
hi try this
dk_4_asp
Participant
904 Points
361 Posts
Re: Connect to SQL Server Express using ASP.NET
Jul 27, 2010 01:15 PM|LINK
you can create a connection to your database using Server Explorer in IDE. And when you successfull create a connection to your database then just right click your connection in server explorer and click properties option. Now in properties you will g et a connection string which will 100% help you.
Mark as answer if you get your answer.
DK
India