using system;
using system.data;
using system.data.oledb;
using system.collections;
namespace xlang.videoonline.framework.database.access
{
/// <summary>
/// summary description for access_datatablescollection.
/// </summary>
public class datatablescollection
{
private database.access.datatable[] _tables;
private int _count;
public int count
{
get
{
return _count;
}
}
public datatablescollection(oledbconnection connection)
{
system.data.datatable schematable = connection.getoledbschematable(oledbschemaguid.tables,
new object[] {null, null, null, "table"});
_count=schematable.rows.count+1;
_tables=new database.access.datatable[_count];
for(int i=0;i<_count-1;i++)
{
_tables[i]=new database.access.datatable(schematable.rows[i][2].tostring());
}
_tables[_count-1]=new database.access.datatable("temp");
}
public database.access.datatable this [int tableindex]
{
get
{
return _tables[tableindex];
//return this[tableindex];
}
set
{
_tables[tableindex]=value;
//this[tableindex]=value;
}
}
public database.access.datatable this [string tablename]
{
get
{
return this [nametoindex(tablename)];
//return this[tablename];
}
set
{
this [nametoindex(tablename)]=value;
//this[tablename]=value;
}
}
private int nametoindex(string tablename)
{
for(int i=0;i<_tables.length;i++)
{
if(_tables[i].name.toupper()==tablename.toupper())
return i;
}
return -1;
}
}
}
