imports system imports system.data imports system.data.oledb
public class getdatabaseschema inherits system.web.ui.page protected withevents datagrid2 as system.web.ui.webcontrols.datagrid protected withevents datagrid3 as system.web.ui.webcontrols.datagrid protected withevents datagrid4 as system.web.ui.webcontrols.datagrid protected withevents datagrid5 as system.web.ui.webcontrols.datagrid protected withevents datagrid6 as system.web.ui.webcontrols.datagrid protected withevents datagrid1 as system.web.ui.webcontrols.datagrid
#region " web form designer generated code " <system.diagnostics.debuggerstepthrough()> private sub initializecomponent()
end sub
private sub page_init(byval sender as system.object, byval e as system.eventargs) _ handles mybase.init initializecomponent() end sub
#end region
private sub page_load(byval sender as system.object, byval e as system.eventargs) _ handles mybase.load '如何得到数据库中的架构信息? 'getoledbschematable函数有两个方法: 'oledbschemaguid 'restrictions '参数oledbschemaguid 的成员:tables, procedures, views, columns, catlogs 等 '参数restrictions为限制条件,是一个对象数组,原来过虑架构结果信息, '每一个对象映射到所返回的datacolumn的值。
dim strcnn as string strcnn = "provider=sqloledb; data source=./netsdk; initial catalog=pubs;user id=sa;password=;" dim dataconn as new oledbconnection(strcnn) try dataconn.open() dim schematable as datatable schematable = dataconn.getoledbschematable(oledbschemaguid.tables, nothing) '得到全部的表、视图 datagrid1.datasource = schematable datagrid1.databind()