I'm having a problem writing aconnection string in .NET. I'm trying to use:
SqlConnection myConnection = new SqlConnection("Provider=SQLOLEDB;Data Source=mssql;Initial Catalog= cat;UserId=ddd;Password=ddd;");
which unfortunately is giving me:
SQL Server does not exist or access denied.
Description: An unhandled exception occurred during the execution ofthe current web request. Please review the stack trace for moreinformation about the error and where it originated in the code.
Can someone tell me what I'm doing wrong? Thanks in advance!

do you only have Windows Authentication setup for your SQL server?
or - if not -does the user you put in the connection string actually have an account in SQL Server?
|||We're not using Windows Authentication and there is a valid account being referenced in the SQL Server (I just put letters in my post to show what I was using)|||
mtarby:
SqlConnection myConnection = new SqlConnection("Provider=SQLOLEDB;Data Source=mssql;Initial Catalog= cat;UserId=ddd;Password=ddd;");
May be a silly question: can Provider key word be used in SqlConnection object? How about remove the Provider attribute from the connection string?
|||Without wanting to come across as too condescending, i'm taking it that your server is called mssql (and it's the only instance on your machine) and that the username and password are correct...?|||Yes, those are just placeholders I put in my post. The server, user name and password are all correct in my actual code|||have you tried:
SqlConnection myConnection = new SqlConnection("Server= YourSrvr; Database=YourDB;UserId=ddd;Password=ddd;");|||I ended up adding an entry to my web.config file and its working fine now. Thanks for the help!
No comments:
Post a Comment