using System;
using System.Data.Odbc;
class Program
{
static void Main(string[] args)
{
string odbcConnectString = "DRIVER={SQL Server};SERVER=(local);" +
"DATABASE=AdventureWorks;Trusted_Connection=yes;";
string sqlSelect = "SELECT TOP 5 Title, FirstName, LastName FROM Person.Contact";
using (OdbcConnection connection =new OdbcConnection(odbcConnectString))
{
OdbcCommand command = new OdbcCommand(sqlSelect, connection);
connection.Open( );
OdbcDataReader reader = command.ExecuteReader( );
while (reader.Read( ))
Console.WriteLine("{0} {1}", reader[0], reader[1]);
}
}
}
|