首页 > 数据库 > Access > 正文

ACCESS数据库访问组件(四)

2024-09-07 19:04:57
字体:
来源:转载
供稿:网友

using system;
using system.data;
using system.data.oledb;
using system.collections;


namespace xlang.videoonline.framework.database.access
{
/// <summary>
/// summary description for access_dataviewscollection.
/// </summary>
public class dataviewscollection
{
private database.access.dataview[] _views;

private int _count;

public int count
{
get
{
return _count;
}
}


public dataviewscollection(oledbconnection connection)
{
system.data.datatable schematable = connection.getoledbschematable(oledbschemaguid.tables,
new object[] {null, null,null, "view"});

_count=schematable.rows.count;
_views=new database.access.dataview[_count];

for(int i=0;i<_count;i++)
{
_views[i]=new database.access.dataview(schematable.rows[i][2].tostring());
}
}


public database.access.dataview this [int tableindex]
{
get
{
return _views[tableindex];
}
set
{
_views[tableindex]=value;
}
}


public database.access.dataview this [string viewname]
{
get
{
return this [nametoindex(viewname)];
}
set
{
this [nametoindex(viewname)]=value;
}
}


private int nametoindex(string viewname)
{
for(int i=0;i<_views.length;i++)
{
if(_views[i].name.toupper()==viewname.toupper())
return i;
}
return -1;
}



}
}



发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表