Using system;
Using system. Collections. Generic;
Using system. text;
Using system. Data;
Using system. Data. oledb;
Namespace SQL
{
Class Program
{
Static void main (string [] ARGs)
{
String SQL = @ "provider = Microsoft. Jet. oledb.4.0;" +
"Data Source = MSG. mdb ";
Oledbconnection conn = new oledbconnection (SQL );
Try {
Conn. open ();
Oledbcommand command = conn. createcommand ();
Command. commandtext = "select * from data ";
Oledbdatareader datareader = command. executereader ();
Console. writeline ("{0, 8} {1, 4}", "ID", "name ");
While (datareader. Read ())
{Console. writeline ("{0, 8}, {1, 4}", datareader ["ID"], datareader ["myname"]);
}
Datareader. Close (); // close
Conn. Close (); // close the database connection
}
Catch (exception E)
{
Console. writeline ("worong ");
}
}
}
}
The created table is:
Data: Put the access file in the bin/debug folder and connect to the database in a simple DOS environment.
The ASP idea is much clearer than JSP. Of course, there are many ways to connect to the database
Connecting to the database is not an esoteric technology, but a very simple technology, so here is just my note