In development, there are many MSSQL statements, but few access databases. The following describes the connection settings of the Access database:
Web. config Configuration
<Configuration>
<Appsettings/>
<Connectionstrings>
<Add name = "myjetconn" connectionstring = "provider = Microsoft. jet. oledb.4.0; Data Source = | datadirectory |/skdb. MDB; persist Security info = false; "providername =" system. data. oledb "/>
</Connectionstrings>
Code used to test the connection status:
Public String opendb ()
{
String MSG;
Oledbconnection myoledb = new oledbconnection ();
Myoledb. connectionstring = webconfigurationmanager. connectionstrings ["myjetconn"]. connectionstring;
Try
{
Myoledb. open ();
MSG = "server vision:" + myoledb. serverversion + "connection is" + myoledb. state. tostring ();
Return (MSG );
}
Catch (exception ERR)
{
MSG = err. message;
Return (MSG );
}
Finally {
Myoledb. Close ();
}
}