I,Use the SQL Sever. NET database provider to connect to SQL Server
<! -- Integrated Security = true indicates that Windows Authentication mode is used -->
<Add key = "connectionstring2" value = "Data Source = LENOVO-THINK; initial catalog = UDS; Integrated Security = true"/>
<! -- The first example is a very basic connection string that can be used to establish a connection to sqlserver on the same machine running the code -->
<Add key = "connectionstring1" value = "Server = (local); database = UDS; user id = sa; Pwd =;"/>
<! -- The second example shows a connection string that can be used to connect to the remote server LENOVO-THINK that uses SQL Server Authentication. In fact, this example is still connected to the local machine -->
<Add key = "connectionstring" value = "Server = LENOVO-THINK; database = UDS; user id = sa; Password =; connection timeout = 60"/>
This is in the web. in the config file, an app key "connectionstring" is created, and the required database connection string (value) is saved. In this way, when you create a connection in webform, you only need to read the connectionstring value. The specific code is as follows.
Dim connstr as string
Connstring = configurationsettings. receivetting ("connectionstring ")
Dim cnsqlserver as new sqlconnection (connstr)
Cnsqlserver. Open
2. Use the oledb. NET database provider to connect to access
Dim cnaccess as new oledbconnection
Cnaccess. connectionstring = "provider = Microsoft. Jet. oledb.4.0; Data Source = C:/webdb/UDS. mdb"
Cnaccess. open ();
Cnaccess. Close ();
3. Use the oralce. NET database provider to connect to Oracle
First of all, I want to tell you not to think that there is anything profound and profound about connecting to Oracle. In fact, there are not many connections to SQL Server.
<Connectionstrings>
<Add name = "applicationservices"
Connectionstring = "Data Source =./sqlexpress; Integrated Security = sspi; attachdbfilename = | datadirectory |/aspnetdb. MDF; user instance = true"
Providername = "system. Data. sqlclient"/>
<Add name = "mitaczp" connectionstring = "Data Source = hrweb_11g; user = HR; Password = HR;" providername = "system. Data. oracleclient"/>
</Connectionstrings>
After reading my blog, please leave a message and I will reply as far as I can.