?? datareader.cs
字號(hào):
using System;
using System.Data.OleDb;
public class DataReader
{
public static int Main(string[] args)
{
string source = "Provider=SQLOLEDB;" + Login.Connection ;
string select = "SELECT ContactName,CompanyName FROM Customers" ;
OleDbConnection conn = new OleDbConnection ( source ) ;
try
{
conn.Open ( ) ;
OleDbCommand cmd = new OleDbCommand ( select , conn ) ;
OleDbDataReader aReader = cmd.ExecuteReader ( ) ;
while ( aReader.Read ( ) )
Console.WriteLine ( "'{0}' from {1}" , aReader.GetString(0) , aReader.GetString ( 1 ) ) ;
aReader.Close ( ) ;
conn.Close ( ) ;
}
catch ( Exception e )
{
Console.WriteLine ( e ) ;
Console.WriteLine ( ) ;
Console.WriteLine ( "Chances are your database does not have a user" ) ;
Console.WriteLine ( "called QSUser, or you do not have the NetSDK database installed." ) ;
}
return 0;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -