C# AccessStruct
using System;
using System.Collections;
using System.Data;
using System.Data.OleDb;
namespace RookIEBox.Net{
public class AccessStruct{
private const string SQL_INSERT_EMAIL = "INSERT INTO [Email] VALUES(@Email)";
private const string SQL_INSERT_URL = "INSERT INTO [Page] VALUES(@Url,@Depth,false)";
private const string SQL_SELECT_URL = "SELECT [Url],[Depth] FROM [Page] WHERE [Peeked] = false AND [Depth] < @Depth ORDER BY [Depth]";
private const string SQL_UPDATE_URL = "UPDATE [Page] SET [Peeked] = true WHERE [Url] = @Url";
private const string CONN_STRING = @"Provider=Microsoft.Jet.OLEDB.4.0;User ID=admin;Data Source=E:\RookieSoft\cache.mdb";
private OleDbConnection _conn = null;
public AccessStruct(){
_conn = new OleDbConnection(CONN_STRING);
_conn.Open();
}
~AccessStruct(){
_conn.Close();
}
public void EnumTables()
{
DataTable table = _conn.GetOleDbSchemaTable(OleDbSchemaGuid.Columns,
new object[] {null, null, "MapDataType", null});
foreach(DataRow drow in table.Rows){
System.Console.WriteLine(drow[2].ToString() + " :: " + drow[3].ToString() + " :: " + drow[8].ToString() + " :: " + drow[10].ToString() + " :: " + drow[11].ToString() + " :: " + drow[12].ToString() + " :: " + drow[13].ToString() + " :: " + drow["DESCRIPTION"].ToString());
}
//foreach(DataColumn dcol in table.Columns){
// System.Console.WriteLine("::" + dcol.ColumnName);
//}
}
public void EnumColumns(string tableName)
{
DataTable table = _conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,
new object[] {null, null, null, "TABLE"});
foreach(DataRow drow in table.Rows){
System.Console.WriteLine(drow[2].ToString() + " :: " + drow[5].ToString());
}
foreach(DataColumn dcol in table.Columns){
System.Console.WriteLine("::" + dcol.ColumnName);
}
}
public static void Main(){
AccessStruct acs = new AccessStruct();
acs.EnumTables();
}
}
}
using System.Collections;
using System.Data;
using System.Data.OleDb;
namespace RookIEBox.Net{
public class AccessStruct{
private const string SQL_INSERT_EMAIL = "INSERT INTO [Email] VALUES(@Email)";
private const string SQL_INSERT_URL = "INSERT INTO [Page] VALUES(@Url,@Depth,false)";
private const string SQL_SELECT_URL = "SELECT [Url],[Depth] FROM [Page] WHERE [Peeked] = false AND [Depth] < @Depth ORDER BY [Depth]";
private const string SQL_UPDATE_URL = "UPDATE [Page] SET [Peeked] = true WHERE [Url] = @Url";
private const string CONN_STRING = @"Provider=Microsoft.Jet.OLEDB.4.0;User ID=admin;Data Source=E:\RookieSoft\cache.mdb";
private OleDbConnection _conn = null;
public AccessStruct(){
_conn = new OleDbConnection(CONN_STRING);
_conn.Open();
}
~AccessStruct(){
_conn.Close();
}
public void EnumTables()
{
DataTable table = _conn.GetOleDbSchemaTable(OleDbSchemaGuid.Columns,
new object[] {null, null, "MapDataType", null});
foreach(DataRow drow in table.Rows){
System.Console.WriteLine(drow[2].ToString() + " :: " + drow[3].ToString() + " :: " + drow[8].ToString() + " :: " + drow[10].ToString() + " :: " + drow[11].ToString() + " :: " + drow[12].ToString() + " :: " + drow[13].ToString() + " :: " + drow["DESCRIPTION"].ToString());
}
//foreach(DataColumn dcol in table.Columns){
// System.Console.WriteLine("::" + dcol.ColumnName);
//}
}
public void EnumColumns(string tableName)
{
DataTable table = _conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,
new object[] {null, null, null, "TABLE"});
foreach(DataRow drow in table.Rows){
System.Console.WriteLine(drow[2].ToString() + " :: " + drow[5].ToString());
}
foreach(DataColumn dcol in table.Columns){
System.Console.WriteLine("::" + dcol.ColumnName);
}
}
public static void Main(){
AccessStruct acs = new AccessStruct();
acs.EnumTables();
}
}
}