开发者

How to connect to SQL Server 2008 database at runtime in configuration file?

开发者 https://www.devze.com 2023-03-10 10:36 出处:网络
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.

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" 
     connectionS开发者_如何学运维trings="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..


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.


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;
0

精彩评论

暂无评论...
验证码 换一张
取 消