SQL Server Access ADO

Source: Internet
Author: User
Tags table name
ado|server| Access
SQL Server Access ADO

----Normally we have only heard of a class of ASP objects such as ADO, but in the ASP also has a little-known specialized SQL Server ASP Access object, it is the Sqlole.sqlserver object. Sqlole. SQL Server has direct access to the system properties of the. With Set oSQLServer = CreateObject ("SQLOLE.") SQL Server ") statement will result in the creation of a server object.

----To view a collection of databases in this server, you can phrase:

For each sqldb in osqlserver.databases
Response.Write Sqldb. Name ' will list all the databases, such as pubs and so on
Next

----To view a collection of data tables in a database, such as the pubs database, you can phrase:

Pubdatabase=osqlserver.databases ("pubs")
' oSQLServer is the SQL Server server object that was created earlier
For each dbtable in Pubdatabase.tables
Response.Write Dbtable.name
Next

----The following statement lists the data view in the database (pubs database)

Pubdatabase =osqlserver.databases ("pubs")
' oSQLServer is the SQL Server server object that was created earlier
For each dbview in Pubdatabase.views
Response.Write Dbview.text
Next

----The following statement lists the storage process in the database (pubs database)

Pubdatabase =osqlserver.databases ("pubs")
' oSQLServer is the SQL Server server object that was created earlier
For each dbsp in Pubdatabase.storedprocedures
Response.Write dbsp. Text
Next

----The results of the program running (Take the data table name):

----The results of the storage process:

----A complete small example of the source code attached (other features readers can join).

<%@ LANGUAGE = VBScript% >

< HTML >
< head >
< META name= "generator" content=
"Microsoft Developer Studio" >
< META http-equiv= "Content-type"
Content= "text/html; charset=gb2312 ">

< TITLE ></title >

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


strserver = "DEP"
Strlogin = "sa"
Strpwd = ""


Osqlserver.connect strserver,strlogin,strpwd


% >


< body bgcolor= #ffffff >
Database list
< 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 >





Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.