vbs版sql查询分析器lcx作品
作者 佚名
来源 ASP编程
浏览
发布时间 2013-07-09
ric_Precision") & vbclrf echo "允许为空:" & rsColumn("Is_Nullable") & vbclrf echo "默认值:" & rsColumn("Column_Default") & vbclrf&vbclrf rsColumn.MoveNext Loop rsTable.MoveNext echo vbcrlf Loop echo "===============================================================" conn.Close Set conn = Nothing Set rsTable = Nothing Set rsColumn = Nothing End Sub Sub showQuery() Dim i, j, rs, sql, page, conn, sqlStr, connStr, rsTable, tablesStr, theTable sqlStr = Wscript.Arguments(1) theTable = Wscript.Arguments(2) sql=Wscript.Arguments(3) page=Wscript.Arguments(4) 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 "数据库表结构查看:" echo tablesStr & "========================================================" echo ">SQL命令执行及查看<:"&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操作 - 执行结果"&vbcrlf echo "===================="&theTable&"列名如下========================================" 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 " 共有"&rs.Fields.Count&"列" & vbcrlf For i = 1 To rs.PageCount page=i Next echo " 共有" & page & "页" rs.Close Else If sql <> "" Then conn.Execute(sql) chkErr(Err) echo "执行完毕!"&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 = "文本" Case 2 getDataType = "整型" Case 3 getDataType = "长整型" Case 7 getDataType = "日期/时间" Case 5 getDataType = "双精度型" Case 11 getDataType = "是/否" Case 128 getDataType = "OLE 对象" Case Else getDataType = typeId End Select End Function Function getTableList(conn, sqlStr, rsTable) Set rsTable = conn.OpenSchema(20, Array(Empty, Empty, Empty, "table")) echo "存在以下表名:" Do Until rsTable.Eof getTableList = getTableList & "["& rsTable("Table_Name") & "]"&vbcrlf rsTable.MoveNext Loop rsTable.MoveFirst End Function |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |
你可能对下面的文章感兴趣
上一篇: 可以查询系统用户名sid的vbs下一篇: 显示运行对话框内保存的命令历史的vbs
关于vbs版sql查询分析器lcx作品的所有评论