日期:2012-06-04  浏览次数:21039 次

---- 以下语句将列出数据库中(PUBS数据库)存贮过程

pubDatabase =oSQLServer.Databases(“pubs”)
’oSQLServer是前面创建的SQL Server服务器对象
For Each DBSP In pubDatabase.StoredProcedures
Response.Write DBSP.Text
Next

---- 程序运行的结果(取数据表名):

---- 取存贮过程的结果:

---- 一个完整的小例子源码附后(其它功能读者可加入)。

< %@ LANGUAGE = VBScript % >

< HTML >
< HEAD >
< META NAME="GENERATOR" Content=
"Microsoft Developer Studio" >
< META HTTP-EQUIV="Content-Type"
content="text/html; charset=gb2312" >

< TITLE >< /TITLE >
< /HEAD >

< %
On Error Resume Next
Dim oSQLServer
Set oSQLServer = CreateObject ("SQLOLE.SQLServer")


strServer = "dep"
strLogin = "sa"
strPwd = ""


oSQLServer.Connect strServer,strLogin,strPwd


% >


< BODY BGCOLOR=#ffffff >
数据库列表
< SELECT NAME="Database" >
< %
For Each SQLDB In oSQLServer.Databases
If Not SQLDB.SystemObject Then
Response.Write "< OPTION VALUE=
""" & SQLDB.Name & """ >" & SQLDB.Name

& " "
End If
Next
Set oSQLServer = Nothing
% >
< /SELECT >
< /BODY >
< /HTML >