.NET Framework Data Provider for SQL Server
April 29, 2009 Leave a comment
Currently a very rapidly growing application is the application that made associated with the database, one of the technology that almost people uses is the . NET scripting technology with the SQL Server database that developed by Microsoft Corp.
to connect application with the SQL server database , it takes the data provider as a connection,
how to connect our .NET aplication with database SQL server?
here’s the code :
(the code can be include in our .NET aplication code)
Standard Security
Data Source=myServerAddress;Initial Catalog=myDataBase;User;Password=myPassword;
Use serverName\instanceName as Data Source to connect to a specific SQL Server instance.
if we use SQL Server 2005 Express, type the server name syntax Servername\SQLEXPRESS where we substitute Servername with the name of the computer where the SQL Server 2005 Express installed.
Standard Security alternative syntax
This connection string produce the same result as the previous one. The reason to include it is to point out that some connection string keywords have many equivalents.
Server=myServerAddress;Database=myDataBase;User ID=myUsername;Password=myPassword;Trusted_Connection=False;
Trusted Connection
Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;
Trusted Connection alternative syntax
This connection string produce the same result as the previous one. The reason to include it is to point out that some connection string keywords have many equivalents.
Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;
Connecting to an SQL Server instance
The syntax of specifying the server instance in the value of the server key is the same for all connection strings for SQL Server.
Server=myServerName\theInstanceName;Database=myDataBase;Trusted_Connection=True;
Attach a database file on connect to a local SQL Server Express instance
Server=.\SQLExpress;AttachDbFilename=c:\mydbfile.mdf;Database=dbname; Trusted_Connection=Yes;
Why is the Database parameter needed? If the named database have already been attached, SQL Server does not reattach it. It uses the attached database as the default for the connection.
thats the code that we needed to connect the aplication with database.
source from : http://www.connectionstrings.com/sql-server-2005