如何从 Windows 中的命令行为 *.accdb 创建用户 DSN?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12744071/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to create User DSN for *.accdb from commandline in Windows?
提问by brainless
I work in an environment where DSN-Less connection is not possible due to some restrictions. I need to create User DSN for "Microsoft Access Driver (*.mdb,*.accdb)". the .accdb file is located in local disk.
由于某些限制,我在无法进行无 DSN 连接的环境中工作。我需要为"Microsoft Access Driver (*.mdb,*.accdb)". .accdb 文件位于本地磁盘中。
I have tried C:\>odbcconf configdsn "Microsoft Access Driver (*.
mdb,*.accdb)" "DSN=crt1|SERVER=c:\a.accdb". But this doesn't seem to work.
我试过了C:\>odbcconf configdsn "Microsoft Access Driver (*.
mdb,*.accdb)" "DSN=crt1|SERVER=c:\a.accdb"。但这似乎不起作用。
How to do it?
怎么做?
回答by bohica
odbcconf configdsn "SQL Server" "DSN=fred|Database=dave"
works for me. I don't have a 64 bit MS Access driver on this 64 bit machine to try. You don't show the error. Why not add /Lv x.log and see what is in the log file.
对我来说有效。我在这台 64 位机器上没有 64 位 MS Access 驱动程序可以尝试。你没有显示错误。为什么不添加 /Lv x.log 并查看日志文件中的内容。
However, is this a 64 bit machine? If it is I doubt you've got a 64 bit MS Access driver installed and odbcconf will be attempting to add a 64 bit DSN. If it works with c:\windows\syswow64\odbcconf then that will likely be your answer.
但是,这是64位机器吗?如果我怀疑您是否安装了 64 位 MS Access 驱动程序,odbcconf 将尝试添加 64 位 DSN。如果它适用于 c:\windows\syswow64\odbcconf 那么这可能就是你的答案。
c\windows\syswow64\odbcconf configdsn "Microsoft Access Driver (*.mdb)" "DSN=fred;Database=dave"
works for me to create a 32 bit DSN.
为我创建一个 32 位 DSN。
回答by Ben
You have a mistake in typing:
Microsoft Access Driver (*.mdb, *.accdb)is correct and works for me (there is a space between *.mdb and *.accdb)
你打字有误:
Microsoft Access Driver (*.mdb, *.accdb)是正确的,对我有用(*.mdb 和 *.accdb 之间有一个空格)
回答by Ben Reisner
For me I had to use the following command. note the DBQ instead of Database or Server as mentioned in this thread
对我来说,我不得不使用以下命令。请注意本线程中提到的 DBQ 而不是 Database 或 Server
"c:\WINDOWS\SysWOW64\odbcconf.exe" CONFIGSYSDSN "Microsoft Access Driver (*.mdb, *.accdb)" "DSN=tp_test5;DBQ=c:\trackerpro\database\companydata.mdb"

