Monday, March 19, 2012

Connecting to local SQL Server

Hi,

I am having problems connecting to databases on my local SQL Server, express edition from my website.

The following is the connection string i am using:

Database=MyDatabase;Server=COMP\SQLEXPRESS;User ID=sa;

The error I get is "Login failed for sa"

I have tried other users but no luck. Also, I cant seem to create a new user as I don't have administrators rights, any ideas how i can do this?

Any ideas?

did you try it this way

<add name="CommerceTemplate" connectionString="Data Source=Comp.Name\SQLEXPRESS;Initial Catalog=dbname;Trusted_Connection=True;"
providerName="System.Data.SqlClient" />

hope this helps

|||

see

www.connectionstrings.com

for help

|||

Hi,

From your description, it seems that you are using "sa" account to log in your SQLServer, that is to say you have set your SQLServer as "SQL Mixed Authentication mode", right?

Based on the error message, there are two possibilities. First, try to log into your SQLServer by SQLServer Management Studio with the 'sa' account, to see if it can work. If not, I guess the account and password maybe invalid. Second, if you are using Windows Authentication mode, you should also make your connection string looks like:

"data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"

Thanks.

No comments:

Post a Comment