using System;
using System.Data;
using System.Data.OleDb;
namespace Access
{
public partial class SelectAllWhereDepartment
{
static private OleDbConnection connection = new OleDbConnection();
static private OleDbDataAdapter dataAdapter = new OleDbDataAdapter();
static private OleDbCommand command = new OleDbCommand();
static private DataTable dataTable = new DataTable();
public static void Main(String[] args)
{
InitDB();
DoSQL();
}
static private void InitDB()
{
connection.ConnectionString = "Provider = Microsoft.ACE.OLEDB.12.0; Data Source = C:\\path\\to\dir\Database1.accdb";
connection.Open();
}
static private void DoSQL()
{
dataTable.Clear();
string sql = "SELECT * FROM rakuten WHERE the_others_party LIKE @the_others_party ";
command.CommandText = sql;
command.Connection = connection;
command.Parameters.Clear();
command.Parameters.AddWithValue("@the_others_party", "%AMAZON%");
dataAdapter.SelectCommand = command;
dataAdapter.Fill(dataTable);
foreach (DataRow dr in dataTable.Rows)
{
Console.WriteLine(dr.ItemArray[1].ToString()+ "," + dr.ItemArray[2].ToString());
}
connection.Close();
}
}
}