当前位置:首页 > 培训职业 > 正文

bat如何查询数据库gdb输出。

bat 做不到,你可尝试写一个VBS脚本,达到目的

建立一个文本文件,复制下段文本到文本文件中,保存。把该文件名修改为

导出.vbs

具体使用时修改下面代码中的三个地方

d:\输出文件名.txt 是输出文件的名字

d:\aaa.mdb 是ACCESS文件的名字

查询1 是你要导出的查询的名字

1234567891011121314151617181920212223242526272829Dim Acc Dim rst Dim db Dim FSO Dim txtFile Dim F Dim strT Set Acc = CreateObject("access.application") Set FSO = CreateObject("Scripting.FileSystemObject") Set txtFile = FSO.CreateTextFile("d:\输出文件名.txt") Acc.OpenCurrentDatabase ("d:\aaa.accdb") Set db = Acc.CurrentDb Set rst = db.OpenRecordset("查询1") For Each F In rst.Fields strT = strT & F.Name & "," Next txtFile.WriteLine Left(strT, Len(strT) - 1) rst.MoveFirst Do While Not rst.EOF strT = "" For Each F In rst.Fields strT = strT & F & "," Next txtFile.WriteLine Left(strT, Len(strT) - 1) rst.MoveNext Loop txtFile.Close rst.Close Acc.Quit

多重随机标签

猜你喜欢文章