将你的constr定义如下:
constr = "Provider = Microsoft.Jet.OLEDB.4.0Data Source = " &Server.MapPath("#khKEY.asp")
&" User ID=adminPassword=Jet OLEDB:Database Password=12345"
就可以连接你的 mdb 数据库了
<%Set conn=Server.CreateObject("ADODB.Connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0Data Source="&Server.MapPath("1.mdb")
conn.Open connstr
sql="insert into 2 (name,pass) values ('"&request("name")&"','"&request("textfield2")&"')"
conn.execute sql
conn.close
set conn=nothing
%>
Provider=Microsoft.Jet.OLEDB.4.0Jet OLEDB:Database Password=123456Data Source=" & Server.MapPath("test.mdb")或者
dim connnews
dim connstrnews
dim DBName
DBname="news.mdb"
connstrnews="DBQ="+server.mappath(dbName)+"DefaultDir=DRIVER={Microsoft Access Driver (*.mdb)}"
set connnews=server.createobject("ADODB.CONNECTION")
connnews.open connstrnews, "uid='admin',pwd='12345'"
connnews.close
或者
dim str_conn,cn
Set cn = Server.CreateObject("ADODB.Connection")
str_conn="Provider=Microsoft.Jet.OLEDB.4.0uid=adminpassword=123456Data Source= " & Server.mappath("../dfang/difang.mdb")
cn.Open str_conn
补充: 改这一句就可以了...
connstr="Provider=Microsoft.Jet.OLEDB.4.0uid=adminpassword=123456Data Source=" &Server.MapPath(mdb)
欢迎分享,转载请注明来源:夏雨云
评论列表(0条)