本文整理汇总了C#中System.Data.OleDb.OleDbCommand类的典型用法代码示例。如果您正苦于以下问题:C# OleDbCommand类的具体用法?C# OleDbCommand怎么用?C# OleDbCommand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OleDbCommand类属于System.Data.OleDb命名空间,在下文中一共展示了OleDbCommand类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadMyData
public void ReadMyData(string connectionString)
{
string queryString = "SELECT OrderID, CustomerID FROM Orders";
using (OleDbConnection connection = new OleDbConnection(connectionString))
{
OleDbCommand command = new OleDbCommand(queryString, connection);
connection.Open();
OleDbDataReader reader = command.ExecuteReader();
while (reader.Read())
{
Console.WriteLine(reader.GetInt32(0) + ", " + reader.GetString(1));
}
// always call Close when done reading.
reader.Close();
}
}
示例2: new OleDbCommand(String SQL)
//引入命名空间
using System;
using System.Data;
using System.Data.OleDb;
class MainClass
{
[STAThread]
static void Main(string[] args)
{
string ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\Northwind.mdb";
string SQL = "SELECT * FROM Orders";
OleDbConnection conn = new OleDbConnection(ConnectionString);
OleDbCommand cmd = new OleDbCommand(SQL);
cmd.Connection = conn;
conn.Open();
OleDbDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
Console.Write("OrderID:"+reader.GetInt32(0).ToString() );
Console.Write(" ,");
Console.WriteLine("Customer:" + reader.GetString(1).ToString() );
}
reader.Close();
conn.Close();
}
}