国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

利用OleDb的GetOLEDBSchemaTable方法得到數據庫架構信息

2024-07-21 02:23:06
字體:
來源:轉載
供稿:網友
我們可以利用oledb的getoledbschematable方法得到數據庫的所有視圖,表,存儲過程等信息。

getdatabaseschema.aspx

<%@ page language="vb" autoeventwireup="false" codebehind="getdatabaseschema.aspx.vb"
inherits="aspxweb.getdatabaseschema"%>
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<title>getdatabaseschama</title>
<meta name="generator" content="microsoft visual studio.net 7.0">
<meta name="code_language" content="visual basic 7.0">
<meta name="vs_defaultclientscript" content="javascript">
<meta name="vs_targetschema" content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<body ms_positioning="gridlayout">
<form id="form1" method="post" runat="server">
<asp:datagrid id="datagrid1" runat="server"></asp:datagrid><br>
<asp:datagrid id="datagrid2" runat="server"></asp:datagrid><br>
<asp:datagrid id="datagrid3" runat="server"></asp:datagrid><br>
<asp:datagrid id="datagrid4" runat="server"></asp:datagrid><br>
<asp:datagrid id="datagrid5" runat="server"></asp:datagrid><br>
<asp:datagrid id="datagrid6" runat="server"></asp:datagrid>
</form>
</body>
</html>

getdatabaseschema.aspx.vb

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

schematable = dataconn.getoledbschematable(oledbschemaguid.tables, new object() {nothing, nothing, nothing, "table"})
'得到全部的用戶表,用戶表類型為table,進行過慮
datagrid2.datasource = schematable
datagrid2.databind()

schematable = dataconn.getoledbschematable(oledbschemaguid.tables, new object() {nothing, nothing, nothing, "view"})
'得到全部的視圖
datagrid3.datasource = schematable
datagrid3.databind()

schematable = dataconn.getoledbschematable(oledbschemaguid.procedures, nothing)
'得到全部的存儲過程
datagrid4.datasource = schematable
datagrid4.databind()

schematable = dataconn.getoledbschematable(oledbschemaguid.provider_types, nothing)
'得到全部支持的數據類型
datagrid5.datasource = schematable
datagrid5.databind()

schematable = dataconn.getoledbschematable(oledbschemaguid.primary_keys, nothing)
datagrid6.datasource = schematable
datagrid6.databind()
catch ex as exception
response.write(ex.message.tostring())
finally
dataconn.close()
end try

end sub

end class




收集最實用的網頁特效代碼!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 雅江县| 贺州市| 益阳市| 韶山市| 璧山县| 凌源市| 奉节县| 乌拉特后旗| 汉川市| 河西区| 鸡西市| 改则县| 长子县| 阿瓦提县| 平泉县| 新晃| 衡阳市| 镇巴县| 平陆县| 宾阳县| 大同市| 上蔡县| 钟山县| 钟祥市| 西华县| 开封市| 景德镇市| 米脂县| 阳西县| 寿光市| 双城市| 云林县| 潼关县| 腾冲县| 红安县| 东源县| 邵阳县| 宕昌县| 永春县| 靖西县| 庆元县|