为什么我无法连接到我的访问数据库 [英] Why can't I connect to my access database
问题描述
我正在创建一个Microsoft Access 2010数据库,该数据库将作为客户端的小型网站的一部分.我已经使用消息框对其进行了调试,并且能够使用VBScript接受数据(客户端可以选择选择,因为他们愿意更新/维护网站内容),我可以调用将数据发送到的子程序.数据库,但我无法超越与数据库的连接.这是我所拥有的:
I'm creating a Microsoft Access 2010 database that will be part of a small web site for a client. I've debugged it with message boxes and I'm able to accept the data with the VBScript (client's choice as they are willing to update/maintain the web site contents), I'm able to call the sub that sends the data to the database, but I can't get past the connection to the database. Here's what I have:
Sub InsertIntoDatabase(FullName)
Dim strSQL, strConnect, strSQL2, i
Dim conn
Set conn = CreateObject("ADODB.Connection")
strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\userID\Desktop\My Stuff\MyData.accdb"
' Cannot get past this point. It's like I cannot connect to the path above.
conn.Open strConnect
strSQL = "INSERT INTO SurveyData (FullName, Address, City, State, Zip, Phone, Email, Pentium, PentiumMMX, Macintosh, Series486, Series386, Win2000, WinNT, WinXP, WinVista, Win7, Unix, Shopping"
strSQL2 = ") VALUES ('" & FullName & "', '" & Address & "', '" & City & "', '" & State & "', '" & Zip & "', '" & Phone & "', '" & Email & "', '" & Pent & "', '" & PentMMX & "', '" & Mac & "', '" & PC486 & "', '" & PC386 & "', '" & Win2000 & "', '" & WinNT & "', '" & WinXP & "', '" & WinVista & "', '" & Win7 & "', '" & Unix & "', '" & Shopping & "'"
' End the query string
strSQL = strSQL & strSQL2 & ")"
' Send the query to the database
conn.Execute strSQL
' Close the connection to the database
conn.Close
strSQL = ""
end sub
我有另一个使用类似脚本且可以正常工作的网站.谁能看到我想念的东西?
I have another web site that uses a similar script and that one works. Can anyone see something I'm missing?
推荐答案
Jet.OLEDB.4.0
提供程序适用于MDB格式的数据库文件.对于较新的ACCDB格式( MyData.accdb ),您需要ACE提供程序.
The Jet.OLEDB.4.0
provider works for MDB format database files. For the newer ACCDB format (MyData.accdb), you need the ACE provider.
对于Access 2007,只有32位版本的ACE提供程序.但是从Access 2010开始,有单独的32位和64位版本.您需要一种与您的VBScript运行所在的位模式匹配的
For Access 2007, there was only a 32 bit version of the ACE provider. But starting with Access 2010, there are separate 32 and 64 bit versions. You need the one which matches the bit mode in which your VBScript runs.
这篇关于为什么我无法连接到我的访问数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!