ASP access SQL Server built-in object
Or usually we only have heard a class of ASP objects such as ADO, but there is a freshly known special SQL Server ASP access object in the ASP, which is the SQLOLE.SQLServer object. SQLOLE.SQLServer can directly access the system properties of SQL Server. A SQL Server server object will be generated by set OSQLServer = CreateObject ("SQLOLE.SQLSERVER" statement.
---- To see a collection of databases in this server, available statements:
For Each Sqldb in OSQLServer.Databases
Response.write sqldb.name 'will list all databases such as Pubs, etc.
NEXT
---- To see a collection of data tables in a database (such as a Pubs database), available statements:
Pubdatabase = OSQLServer.Databases ("Pubs")
'OSQLServer is the SQL Server server object created in front
For Each DBTable in Pubdatabase.tables
Response.write dbtable.name
NEXT
---- The following statement will list the database (PUBS database) data view
Pubdatabase = OSQLServer.Databases ("Pubs")
'OSQLServer is the SQL Server server object created in front
For Each DBVIEW in Pubdatabase.views
Response.write dbview.text
NEXT
---- The following statement will list the database (PUBS database) storage process
Pubdatabase = OSQLServer.Databases ("Pubs")
'OSQLServer is the SQL Server server object created in front
For Each DBSP in Pubdatabase.storedProcedures
Response.write dbsp.text
NEXT
---- The result of the program runs (taking the data table name):
---- Results of the reservoir:
---- After a complete small example source code (other function readers can join).
<% @ Language = VBScript%>
Microsoft Developer Studio>
Content = "text / html; charSet = GB2312">
HEAD>
<%
ON Error ResMe next
DIM OSQLServer
Set OSQLServer = CreateObject ("Sqlole.sqlserver")
STRSERVER = "DEP"
Strlogin = "sa"
Strpwd = ""
Osql Server.Connect Strserver, Strlogin, StrPwd
%>
Database list
<%
For Each Sqldb in OSQLServer.DatabaseSif Not Sqldb.systemObject Then
Response.write "