I've constructed an inventory program that relies on a database for information. Previously, I've used Access 2007, because it is easy and n00b friendly. Unfortunately, I'm not so sure Access can handle the requirements (Multiple simultaneous users over a LAN connection). So I switched to SQL Server 2005 Express. And things went downhill from there.

I wrote my program in such a way that it would read the connection string from an .ini file. It has no problems locating the .ini file, but upon trying to connect to the database, it always fails.

The latest error goes something like this:
"A network-related or instance-specific error has occured while establishing a connection to SQL Server."

And this is the code I used for it:

integrated security=SSPI;data source=LANCE-PC\SQLEXPRESS\dbaseAIS;Initial Catalog=dBaseAIS;Integrated Security=True;persist security info=False;User ID=Lance;Password=********

I am assuming that something is wrong with the User ID and the Password (the Username I log on to, and the Password to my account in Windows 7, respectively). But I'm not sure how to fix it. This is the closest I got to actually getting to the Database. Using alternative codes such as this:

data source=LANCE-PC\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|dbaseAIS.mdf;User Instance=true

Would get me a Database does not exist or database not found error, or something to that effect.

Could anyone help me with this please? I'm new at SQL.

Edited by zack_falcon: n/a

6 Years
Discussion Span
Last Post by zack_falcon

Hey there, you might want to visit this site http://www.connectionstrings.com/

a sample connection string as mentioned there would look like this:
Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;

PS :NEVER PUT ON YOUR REAL LOGIN DETAILS !!!!!!!!! Anyone can access your server with those details

What you are searching for is to log in with WINDOWS authentication instead of SQL authentication.

You will not require a username or passwrod in your constring

Edited by crazyvonzipper: n/a


The problem might be that you are trying to mix Integrated Security and providing a userid/password. Normally you'd put

Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;

For integrated security and

Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;

For userid/password


Thanks for the link. Does the "Windows Authentication" in SQL Server means that it will use my Windows username / log in details?

Otherwise, is there a default username / password?


This should suffice for your connection string


This should suffice for your connection string


That did it!

Thanks for the quick solution!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.