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()