Reputation: 21
I'm trying to connect to SQL Server 2008 at runtime in a configuration file.
I'm only connect to SQL Server 2008 Express that built-in Visual Studio 2008.
Here is some code that I wrote
<add name="MyName"
connectionStrings="Data Source=.\sqlexpress;AttachDBFileName=|DataDirectory|\Database\mydatabase.mdf;Integrated Security=true;User Instance=true;" />
That code is to connect to SQL Server 2008 Express database.
I want to know which code can connect real SQL Server 2008 database instead of SQL Server Express...
Please answer me if you know... Always respects all of you...
Thanks..
Upvotes: 0
Views: 1193
Reputation: 17956
If I'm using AD authentication, I go with
Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;
If SQL server auth, I use
Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;
Upvotes: 0
Reputation: 85036
Take a look at this link:
http://www.connectionstrings.com/sql-server-2008
It goes over the various ways you can setup your connection strings. Your "typical" connection string (if there is such a thing) will probably look something like this:
Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;
But it really depends on how your SQL Server instance is configured and what kind of security you want to use.
Upvotes: 1