using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.OleDb;
class Program
{
static void Main(string[] args)
{
string oledbConnectString = "Provider=SQLOLEDB; Data Source=(local);" +
"Integrated security=SSPI;Initial Catalog=AdventureWorks;";
string oledbSelect = "SELECT * FROM Sales.SalesOrderHeader WHERE TotalDue > ?";
OleDbConnection oledbConnection = new OleDbConnection(oledbConnectString);
OleDbCommand oledbCommand = new OleDbCommand(oledbSelect, oledbConnection);
oledbCommand.Parameters.Add("@TotalDue", OleDbType.Currency);
oledbCommand.Parameters["@TotalDue"].Value = 200000;
OleDbDataAdapter oledbDa = new OleDbDataAdapter(oledbCommand);
DataTable oledbDt = new DataTable( );
oledbDa.Fill(oledbDt);
foreach (DataRow row in oledbDt.Rows){
Console.WriteLine(row["SalesOrderID"]);
Console.WriteLine(row["OrderDate"]);
Console.WriteLine(row["TotalDue"]);
}
}
}
|