Database connection in ADO.NET (provided by Microsoft)

xiaoxiao2021-03-06  63

In MSDN, the .NET's database connection string has a detailed description, I have some ways of code examples, and the meaning of each representative can be found in the MSDN. ADO.NET Database connection method (Microsoft is provided) Microsoft provides the following four database connection: System.Data.OleDb.OleDbConnectionSystem.Data.SqlClient.SqlConnectionSystem.Data.Odbc.OdbcConnectionSystem.Data.OracleClient.OracleConnection Here we have an example of the way in order to explain: System.Data. SqlClient.SqlConnection some common connection string (C # Code): SqlConnection conn = new SqlConnection ( "Server = (local); Integrated Security = SSPI; database = Pubs"); SqlConnection conn = new SqlConnection ( "server = (local) / NetSDK; database = pubs; Integrated Security = SSPI "); SqlConnection conn = new SqlConnection (" Data Source = localhost; Integrated Security = SSPI; Initial Catalog = Northwind; "); SqlConnection conn = new SqlConnection (" data source = ( local); initial catalog = xr; integrated security = SSPI; persist security info = False; workstation id = XURUI; packet size = 4096; "); SqlConnection myConn = new System.Data.SqlClient.SqlConnection (" Persist Security info = False ; Integrated security = sspi; database = northwind; server = mysqlserver "); SQLConnection conn = new SQLCO Nnection ("UID = SA; PWD = Passwords; Initial Catalog = Pubs; Data Source = 127.0.0.1; Connect Timeout = 900"); More String Connections Please see MSDN: http://msdn.microsoft.com/ library / default.asp url = / library / en-us / cpref / html / frlrfSystemDataSqlClientSqlConnectionClassConnectionStringTopic.asp System.Data.OleDb.OleDbConnection some common connection string (C # Code):? OleDbConnection conn = new OleDbConnection (@ "Provider = Microsoft.jet.Oledb.4.0; data source = d: /myweb5/grocrtogo.mdb "); OLEDBConnection conn = new oledbconnection (@"

Provider = Microsoft.Jet.OLEDB.4.0; Password =; User ID = Admin; Data Source = grocertogo.mdb; "); OleDbConnection conn = new OleDbConnection (" Provider = MSDAORA; Data Source = ORACLE8i7; Persist Security Info = False; Integrated Security = yes "); OleDbConnection conn = new OleDbConnection (" Provider = Microsoft.Jet.OLEDB.4.0; Data Source = c: /bin/LocalAccess40.mdb "); OleDbConnection conn = new OleDbConnection (" Provider = SQLOLEDB; Data Source = mysqlserver; integrated security = sspi "); More string connection notes See msdn: http://msdn.microsoft.com/library/default.asp? URL = / library / en-us / cpref / html / ? frlrfSystemDataOleDbOleDbConnectionClassConnectionStringTopic.asp frame = trueSystem.Data.OracleClient.OracleConnection some common connection string (C # Code): OracleConnection myConn = new System.Data.OracleClient.OracleConnection ( "Data Source = Oracle8i; Integrated Security = yes"); more multi-string connection instructions see MSDN: http: //msdn.microsoft.com/library/default.asp url = / library / en-us / cpref / html / frlrfSystemDataOracleClientOracleConnectionClassConnectionStringTopic.asp frame = trueSystem.Data.Odbc??. O dbcConnection some common connection string (C # Code): OdbcConnection conn = new OdbcConnection ( "Driver = {SQL Server}; Server = MyServer; Trusted_Connection = yes; Database = Northwind;"); OdbcConnection conn = new OdbcConnection ( "Driver = {Microsoft ODBC for Oracle}; Server = ORACLE8i7; Persist Security Info = False; Trusted_Connection = yes "); OdbcConnection conn = new OdbcConnection (" Driver = {Microsoft Access Driver (* .mdb)}; DBQ = c: / bin / NWIND.MDB "); odbcconnection conn = new odbcconnection (" driver = {microsoft excel driver (* .xls)}; dbq =

转载请注明原文地址:https://www.9cbs.com/read-119752.html

New Post(0)