Using system;
Using system. Collections. Generic;
Using system. text;
Using system. Data. ODBC;
Using system. Data. oledb;
Namespace odbctest
{
Class Program
{
Static void main (string [] ARGs)
{
// ODBC connection
String constring = "DSN = Tian"; // Tian indicates the user data source name of ODBC.
String SQL = "select count (*) from stuinfo"; // stuinfo indicates a table in the database bound to the user data source.
Odbcconnection con = new odbcconnection (constring );
Con. open ();
Odbccommand COM = new odbccommand (SQL, con );
Int I = convert. toint32 (COM. executescalar ());
Console. writeline (I );
// oledb connection
string constring = @ "provider = Microsoft. jet. oledb.4.0; Data Source = D: \ Tian. mdb "; // connect to the ACCESS database
string SQL =" select count (*) from stuinfo ";
oledbconnection con = new oledbconnection (constring );
con. open ();
oledbcommand COM = new oledbcommand (SQL, con);
int I = convert. toint32 (COM. executescalar ();
console. writeline (I);
}< BR >}