วันศุกร์ที่ 23 เมษายน พ.ศ. 2553

Simple use on DbProviderFactory

using System.Data.Common;
using System.Collections;

DbProviderFactory factory = DbProviderFactories.GetFactory( "System.Data.OleDb" );

string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Vevo.mdb;";

connection = factory.CreateConnection();

connection.ConnectionString = connectionString;

connection.Open();

DbCommand cmd = connection.CreateCommand();

cmd.CommandText = "SELECT * FROM Page";

DbDataReader reader = cmd.ExecuteReader();

if (!reader.HasRows)
{
reader.Close();
return;
}

ArrayList array = new ArrayList();

while (reader.Read())
{
//result.Add( binder( reader ) );
array.Add( reader );
}

reader.Close();

connection.Close();

ไม่มีความคิดเห็น: