Using system; use system.data.sqlclient; using system.data.oledb; Namespace consoleApplication1 {///
// The following is Connecting Access OledbConnection dbconn = new oledbconnection (@ "provider = microsoft.jet.oledb.4.0; data source = c: /a.mdb"); dbconn.open (); // oleDbcommand cmd = new OLEDBCommand "Select * from test1", dbconn);
OLEDBCOMMAND CMD = dbconn.createCommand (); cmd.commandtext = "select * from test1"; cmd.commandtype = commandType.text; oleDbdatareader reader = cmd.executeReader ();
/ / The following is Connecting SQL2000 / * SQLConnection Conn = New SqlConnection ("Server = localhost; initial catalog = northwind; user ID = sa; password =;"); conn.open (); sqlcommand cmd = conn.createCommand (); cmd.comMandtext = "Select * from customers"; cmd.commandtype = commandType.text; sqldataareader reader = cmd.executeReader (Commandbehavior.CloseConnection); * /
String Output; while (reader.read ()) {Output = string.format ("Custormer {0}: {1} Works for {2}", Reader.getstring (1), Reader.getstring (2), Reader. GetString (3)); console.writeLine (Output);}}}}