Let's take a look at the Access database connection and open it:
String strConnection = "Provider = Microsoft. Jet. OleDb.4.0; Data Source = ";
StrConnection + = Server. MapPath ("*. mdb"); // * indicates the database name.
OleDbConnection objConnection = new OleDbConnection (strConnection );
ObjConnection. Open (); dim objConnection as OleDbConnection
ObjConnection = new OleDbConnection ("Provider = Microsoft. Jet. OleDb.4.0; Data Source =" + Server. MapPath ("*. mdb "))
ObjConnection. Open ()
Next let's take a look at how SQL SERVER connects to the database and opens it:
String strConnection = "server = database connection; uid = user name; pwd = password; database = database name ";
SqlConnediob objConnection = new SqlCOnnection (strConnection );
ObjConnection. Open (); dim objConnection as SqlConnectiom
ObjConnection = new SqlConnection ("server = database connection; uid = username; pwd = password; database = database name ")
ObjConnection. Open ()
In fact, in most cases, the difference between SQL server and ACCESS is not only the connection statement, but also the difference between other definition statements, namely SQL ×× and OLEDB ××.
In addition, if it is an ACCESS database, the following statements must be included at the beginning of the ASPX file:
<% @ Import Namespace = "System. Data" %>
<% @ Import Namespace = "System. Data. OleDb" %>
For SQL SERVER, the following statements are required:
<% @ Import Namespace = "System. Data" %>
<% @ Import Namespace = "System. Data. SqlClient" %>