Spent a little time to the previous Haiyang top 2006 of the SQL module to the VBS version, and its function is the same, but may not be used to use the ASP version of the comfortable, but can be used, can be used in the DOS, infiltrate the intranet when estimated you need.
if (LCase right (wscript.fullname,11) = "Wscript.exe") Then
echo "Execute it under the Cmd.exe plz! Thx."
echo "Code by LCX"
Wscript.Quit
End If
Sub Chkerr (ERR)
If ERR Then
echo "Error:" & Err.Description & "error Source:" & Err.Source & vbCrLf
Err.Clear
Wscript.Quit
End If
End Sub
Sub Echo (str)
WScript.Echo Str
End Sub
Function Fixnull (str)
If IsNull (str) Then
str = ""
End If
Fixnull = str
End Function
Sub Showerr (str)
Dim I, Arraystr
ARRAYSTR = Split (str, "$$")
echo "error message:" &vbcrlf
For i = 0 to UBound (ARRAYSTR)
Echo (i + 1) & "." & Arraystr (i) & "<br/>"
Next
echo vbCrLf
Wscript.Quit
End Sub
Rem =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Rem below is the Program Module selection section
Rem =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Pagemsdatabase ()
Sub Pagemsdatabase ()
Dim Theact, Sqlstr
Theact = wscript.arguments (0)
Sqlstr = wscript.arguments (1)
Select Case Theact
Case "Showtables"
Showtables ()
Case "Query"
Showquery ()
End Select
End Sub
Sub Showtables ()
Dim Conn, sqlstr, Rstable, Rscolumn, ConnStr, Tablesstr
Sqlstr = wscript.arguments (1)
If LCase (Left (SQLSTR, 4)) = "sql:" Then
ConnStr = Mid (sqlstr, 5)
Else
ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Sqlstr
End If
Set conn = CreateObject ("Adodb.connection")
If not IsNumeric (page) or page = "" Then
page = 1
End If
If LCase (Left (SQLSTR, 4)) = "sql:" Then
ConnStr = Mid (sqlstr, 5)
Else
ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Sqlstr
End If
Set rs = CreateObject ("Adodb.recordset")
Set conn = CreateObject ("Adodb.connection")
Conn. Open ConnStr
Chkerr (ERR)
TABLESSTR = gettablelist (conn, sqlstr, rstable)
Echo database table structure view: "
echo Tablesstr & "========================================================"
echo ">sql command execution and view:" &vbcrlf
If SQL <> "" and Left (LCase (SQL), 7) = "Select" Then
Rs. Open SQL, Conn, 1, 1
Chkerr (ERR)
Rs. PageSize = 20
If not Rs. Eof Then
Rs. AbsolutePage = page
End If
If Rs. Fields.count>0 Then
echo "SQL operations-execution Results" &vbcrlf
The echo "====================" &theTable& "column names are as follows ========================================"
For j = 0 to Rs. Fields.count-1
Echo Rs. Fields (j). Name & vbCrLf
Next
For i = 1 to 20
If Rs. Eof Then
Exit for
End If
For j = 0 to Rs. Fields.count-1
Echo Fixnull (RS (j)) & vbCrLf
Next
Rs. MoveNext
Next
End If
echo "================================================================="
echo "Total" &rs. fields.count& "Columns" & vbCrLf
For i = 1 to Rs. PageCount
Page=i
Next
echo "Total" & Page & "Pages"
Rs. Close
Else
If SQL <> "" Then
Conn. Execute (SQL)
Chkerr (ERR)
echo "Done!" &vbcrlf
End If
End If
Conn. Close
Set rs = Nothing
Set conn = Nothing
Set rstable = Nothing
End Sub
Function Getdatatype (typeid)
Select Case typeID
Case 130
Getdatatype = "Text"
Case 2
Getdatatype = "Integral type"
Case 3
Getdatatype = "Long Integral type"
Case 7
Getdatatype = "Date/Time"
Case 5
Getdatatype = "Double-precision"
Case 11
Getdatatype = "Yes/No"
Case 128
Getdatatype = "OLE Object"
Case Else
Getdatatype = typeID
End Select
End Function
Function gettablelist (conn, sqlstr, rstable)
Set rstable = conn. OpenSchema (Empty, Empty, Empty, "table")
echo "has the following table name:"
Do Until rstable.eof
Gettablelist = gettablelist & "[" & Rstable ("table_name") & "]" &vbcrlf
Rstable.movenext
Loop
Rstable.movefirst
End Function
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.