ASP. Net connection SQL server connection string, asp. netsqlserver
1 using System.Data; 2 using System.Data.SqlClient;
1 // windows Authentication mode the database contains a single instance. 2 string connectionString = "Data Source = localhost; Initial Catalog = Northwind; Integrated Security = SSPI; "3 // multi-instance 4 string connectionString =" Data Source = localhost \ SQLEXPRESS; Initial Catalog = Northwind; Integrated Security = True; "5 // SQL Server Verification Method = Data Source = 127.0.0.1 can be connected to the local database 6 string connectionString =" Data Source = 10.1.2.3; Initial Catalog = Northwind; User ID = sa; password = abc123 ";
"Integrated Security = SSPI;" & "Integrated Security = True;" it is equivalent to setting Integrated Security to SSPI or True, that is, use the current Windows Account creden。 for authentication. However, in the ASP. NET program, the current running host environment may be different, and the user to which it points will be different.
① Use ASP in Windows Xp. NET account; ② use the NetWork Service account in Windows 2003 and later; ③ use the user account in the current development environment in Visual Studio, not ASP.. NET account.
When aspnet connects to sql2005, where do I enter the database connection string?
In the web. config configuration file
Add
<ConnectionStrings>
<Add name = "B2CCon" connectionString = "server =. \ SQLexpression; database = name of the database to be connected; integrated security = true"/>
</ConnectionStrings>
How can I use Aspnet to connect to a database if I have only installed windows?
Only local connections are allowed. passwords and users are not set in the connection string. Instead, Integrated Security = true is used;