濮阳杆衣贸易有限公司

主頁 > 知識(shí)庫 > 讀取Access數(shù)據(jù)庫的vbscript代碼打包下載

讀取Access數(shù)據(jù)庫的vbscript代碼打包下載

熱門標(biāo)簽:外呼營銷下單系統(tǒng) 打電話的外呼系統(tǒng)貴不貴 海外美發(fā)店地圖標(biāo)注 前鋒辦理400電話申請 百度地圖標(biāo)注怎么卸載 新密防封卡外呼系統(tǒng)違法嗎 加盟電銷機(jī)器人好的品牌 陜西高頻外呼回?fù)芟到y(tǒng)哪家好 辦理膠州400電話財(cái)稅
效果如圖所示:

核心代碼:
復(fù)制代碼 代碼如下:

Option Explicit
Dim arrTables( ), i, idxTables, intValidArgs
Dim blnContent, blnFieldNames
Dim objConn, objFSO, objRS, objSchema
Dim strConnect, strHeader, strOutput
Dim strFile, strResult, strSQL, strTable
Const adSchemaTables = 20
' Check command line arguments
With WScript.Arguments
If .Unnamed.Count = 1 Then
strFile = .Unnamed(0)
Else
Syntax
End If
blnFieldNames = True
blnContent = True
If .Named.Count > 0 Then
intValidArgs = 0
If .Named.Exists( "T" ) Then
blnFieldNames = False
blnContent = False
intValidArgs = intValidArgs + 1
End If
If .Named.Exists( "TF" ) Then
blnContent = False
intValidArgs = intValidArgs + 1
End If
If intValidArgs > .Named.Count Then Syntax
End If
End With
' Check if the specified database file exists
Set objFSO = CreateObject( "Scripting.FileSystemObject" )
If Not objFSO.FileExists( strFile ) Then Syntax
Set objFSO = Nothing
' Connect to the MS-Access database
Set objConn = CreateObject( "ADODB.Connection" )
strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" strFile
objConn.Open strConnect
' Search for user tables and list them in an array
Set objSchema = objConn.OpenSchema( adSchemaTables )
idxTables = -1
Do While Not objSchema.EOF
If objSchema.Fields.Item(3).Value = "TABLE" Then
idxTables = idxTables + 1
ReDim Preserve arrTables( idxTables )
arrTables( idxTables ) = objSchema.Fields.Item(2).Value
End If
objSchema.MoveNext
Loop
' List all tables, their column names and their contents
For Each strTable In arrTables
strSQL = "Select * From " strTable
Set objRS = objConn.Execute( strSQL )
If IsObject( objRS ) Then
' Display the current table's name
If blnContent Then
WScript.Echo """Table: " strTable """"
Else
WScript.Echo """" strTable """"
End If
If blnFieldNames Then
strOutput = ""
Do While Not objRS.EOF
' Create a header line with the column names and data types
strHeader = ""
For i = 0 To objRS.Fields.Count - 1
strHeader = strHeader ",""[" _
GetDataTypeDesc( objRS.Fields.Item(i).Type ) "] " _
objRS.Fields.Item(i).Name """"
Next
strHeader = Mid( strHeader, 2 )
If blnContent Then
' List the fields of the current record in comma delimited format
strResult = ""
For i = 0 To objRS.Fields.Count - 1
strResult = strResult ",""" objRS.Fields.Item(i).Value """"
Next
' Add the current record to the output string
strOutput = strOutput Mid( strResult, 2 ) vbCrLf
End If
' Next record
objRS.MoveNext
Loop
' List the results for the current table
WScript.Echo strHeader vbCrLf strOutput vbCrLf
End If
End If
Next
objRS.Close
objSchema.Close
objConn.Close
Set objRS = Nothing
Set objSchema = Nothing
Set objConn = Nothing
Function GetDataTypeDesc( myTypeNum )
Dim arrTypes( 8192 ), i
For i = 0 To UBound( arrTypes )
arrTypes( i ) = "????"
Next
arrTypes(0) = "Empty"
arrTypes(2) = "SmallInt"
arrTypes(3) = "Integer"
arrTypes(4) = "Single"
arrTypes(5) = "Double"
arrTypes(6) = "Currency"
arrTypes(7) = "Date"
arrTypes(8) = "BSTR"
arrTypes(9) = "IDispatch"
arrTypes(10) = "Error"
arrTypes(11) = "Boolean"
arrTypes(12) = "Variant"
arrTypes(13) = "IUnknown"
arrTypes(14) = "Decimal"
arrTypes(16) = "TinyInt"
arrTypes(17) = "UnsignedTinyInt"
arrTypes(18) = "UnsignedSmallInt"
arrTypes(19) = "UnsignedInt"
arrTypes(20) = "BigInt"
arrTypes(21) = "UnsignedBigInt"
arrTypes(64) = "FileTime"
arrTypes(72) = "GUID"
arrTypes(128) = "Binary"
arrTypes(129) = "Char"
arrTypes(130) = "WChar"
arrTypes(131) = "Numeric"
arrTypes(132) = "UserDefined"
arrTypes(133) = "DBDate"
arrTypes(134) = "DBTime"
arrTypes(135) = "DBTimeStamp"
arrTypes(136) = "Chapter"
arrTypes(138) = "PropVariant"
arrTypes(139) = "VarNumeric"
arrTypes(200) = "VarChar"
arrTypes(201) = "LongVarChar"
arrTypes(202) = "VarWChar"
arrTypes(203) = "LongVarWChar"
arrTypes(204) = "VarBinary"
arrTypes(205) = "LongVarBinary"
arrTypes(8192) = "Array"
GetDataTypeDesc = arrTypes( myTypeNum )
End Function
Sub Syntax
Dim strMsg
strMsg = strMsg vbCrLf _
"AccessRd.vbs, Version 1.01" vbCrLf _
"Display MS Access database (user) tables and, optionally, their contents" _
vbCrLf vbCrLf _
"Usage: CSCRIPT //NOLOGO ACCESSRD.VBS access_db_file [ /T | /TF ]" _
vbCrLf vbCrLf _
"Where: ""access_db_file"" is an MS-Access database file" vbCrLf _
" /T list table names only" vbCrLf _
" /TF list table and field names only" vbCrLf _
" (default is list tables, field names AND contents)" _
vbCrLf vbCrLf _
"Written by Rob van der Woude" vbCrLf _
"http://www.robvanderwoude.com"
WScript.Echo strMsg
WScript.Quit(1)
End Sub

使用方法:
AccessRd.vbs, Version 1.01Display MS Access database (user) tables and, optionally, their contents
Usage: CSCRIPT //NOLOGO ACCESSRD.VBS access_db_file [ /T | /TF ]Where: "access_db_file" is an MS-Access database file
/T list table names only
/TF list table and field names only
(default is list tables, field names AND contents)Written by Rob van der Woudehttp://www.robvanderwoude.com

測試代碼打包下載
您可能感興趣的文章:
  • VBS教程:屬性-DateLastAccessed 屬性
  • ACCESS的參數(shù)化查詢,附VBSCRIPT(ASP)和C#(ASP.NET)函數(shù)
  • vbs生成ACCESS數(shù)據(jù)里所有表的字段
  • UserAccessList 集合的功能(VBA)
  • excel2access vbs腳本
  • VB6實(shí)現(xiàn)連接Access數(shù)據(jù)庫的ADODB代碼實(shí)現(xiàn)方法
  • VB使用ADO操作Access數(shù)據(jù)庫

標(biāo)簽:牡丹江 河南 伊春 四平 梅州 咸陽 武威 阜陽

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《讀取Access數(shù)據(jù)庫的vbscript代碼打包下載》,本文關(guān)鍵詞  讀取,Access,數(shù)據(jù)庫,的,vbscript,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《讀取Access數(shù)據(jù)庫的vbscript代碼打包下載》相關(guān)的同類信息!
  • 本頁收集關(guān)于讀取Access數(shù)據(jù)庫的vbscript代碼打包下載的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    稻城县| 贺兰县| 凤庆县| SHOW| 赤水市| 班戈县| 乾安县| 富源县| 平泉县| 敦煌市| 红安县| 无极县| 鸡西市| 永宁县| 商水县| 三亚市| 深圳市| 探索| 四子王旗| 南召县| 博兴县| 鱼台县| 东明县| 雷波县| 鄄城县| 谷城县| 额济纳旗| 平原县| 灯塔市| 班戈县| 嘉善县| 贺兰县| 天门市| 鄂温| 溧阳市| 长武县| 北川| 高安市| 安阳市| 新龙县| 临沧市|