ASP连接数据库的连接方法

2024-11-30 09:41:24
推荐回答(5个)
回答1:

set adocon=Server.Createobject(adodb.connection)
adocon.OpenDriver={Microsoft Access Driver (*.mdb)};DBQ=& _
Server.MapPath(数据库所在路径) set adocon=Server.Createobject(adodb.connection)
adocon.openProvider=Microsoft.Jet.OLEDB.4.0;& _
Data Source= & Server.MapPath(数据库所在路径) set adocon=server.createobject(adodb.connection)
adocon.OpenDriver={SQL Server};Server=(Local);UID=***;PWD=***;& _
database=数据库名; set adocon=Server.Createobject(adodb.connection)
adocon.openprovider=SQLOLEDB.1;Data Source=RITANT4;& _
user ID=***;Password=***;& _
inital Catalog=数据库名 set adocon=Server.Createobject(adodb.connection)
adocon.openDriver={microsoft odbc for oracle};server=oraclesever.world;uid=admin;pwd=pass; set adocon=Server.Createobject(adodb.connection)
adocon.openProvider=OraOLEDB.Oracle;data source=dbname;user id=admin;password=pass; set adocon=Server.Createobject(adodb.connection)
adocon.openDriver={microsoft dbase driver(*.dbf)};driverid=277;dbq=------------; set adocon=Server.Createobject(adodb.connection)
adocon.openDriver={mysql};database=yourdatabase;
uid=username;pwd=yourpassword;option=16386; set adocon=Server.Createobject(adodb.connection)
adocon.openDriver={microsoft Visual Foxpro driver};sourcetype=DBC;sourceDB=*.dbc;Exclusive=No; set adocon=Server.Createobject(adodb.connection)
adocon.openDriver={microsoft text driver(*.txt; *.csv)};dbq=-----;&_
extensions=asc,csv,tab,txt;Persist SecurityInfo=false; set adocon=Server.Createobject(adodb.connection)
adocon.openProvider=microsof.jet.oledb.4.0;data source=your_path;&_
Extended Properties'text;FMT=Delimited'

回答2:

不同的数据库连接方式不一样

一、ASP连接Access数据库(DSN-less连接方法):
set adocon=Server.Createobject("adodb.connection")
adoconn.Open"Driver={Microsoft Access Driver(*.mdb)};DBQ="&_Server.MapPath("数据库所在路径")

二、ASP连接Access数据库( OLE DB连接方法):
set adocon=Server.Createobject("adodb.connection")
adocon.open"Provider=Microsoft.Jet.OLEDB.4.0;"&_"Data Source=" & Server.MapPath("数据库所在路径")

三、ASP连接SQL server的方法:
set adocon=server.createobject("adodb.recordset")
adocon.Open"Driver={SQL Server};Server=(Local);UID=***;PWD=***;"& _"database=数据库名;"

三、ASP连接SQL server 通过 OLE DB连接方法:
set adocon=Server.Createobject("adodb.connection")
adocon.open"provider=SQLOLEDB.1;Data Source=RITANT4;"&_"user ID=***;Password=***;"&_"inital Catalog=数据库名"

四、ASP与Oracle数据库的连接方法:
set adocon=Server.Createobject("adodb.connection")
adocon.open"Driver={microsoft odbc for oracle};server=oraclesever.world;uid=admin;pwd=pass;"

五、ASP与Oracle数据库的 OLE DB 连接方法:
set adocon=Server.Createobject("adodb.connection")
adocon.open"Provider=OraOLEDB.Oracle;data source=dbname;user id=admin;password=pass;"

六、ASP连接dBase数据库方法:
set adocon=Server.Createobject("adodb.connection")
adocon.open"Driver={microsoft dbase driver(*.dbf)};driverid=277;dbq=--------;"

七、ASP连接mySQL数据库的方法:
set adocon=Server.Createobject("adodb.connection")
adocon.open"Driver={mysql};database=yourdatabase;uid=username;pwd=yourpassword;option=16386;"

八、ASP连接Visual Foxpro数据库的方法:
set adocon=Server.Createobject("adodb.connection")
adocon.open"Driver={microsoft Visual Foxpro driver};sourcetype=DBC;sourceDB=*.dbc;Exclusive=No;"

九、ASP连接MS text数据库的方法:
set adocon=Server.Createobject("adodb.connection")
adocon.open"Driver={microsoft text driver(*.txt; *.csv)};dbq=---;"&_"extensions=asc,csv,tab,txt;Persist SecurityInfo=false;"

十、ASP连接MS text数据库的OLE DB连接方法:
set adocon=Server.Createobject("adodb.connection")
adocon.open"Provider=microsof.jet.oledb.4.0;data source=your_path;"&_"Extended Properties'text;FMT=Delimited'"

回答3:

access的连接字符串
<%
db="数据库路径"
connstr="DBQ="+server.mappath(""&db&"")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
on error resume next
set conn=server.createobject("ADODB.CONNECTION")
conn.open connstr
if err then
response.write err.discription
Err.Clear
conn.close
set conn=nothing
Response.Write "数据库连接出错,请检查连接字符串。"
Response.End
end if
%>
sqlser连接
<%
Sql_Server = "服务器地址"
Sql_User = "数据库账号"
Sql_Pass = "密码"
Sql_Data = "数据库名"

dim Conn,connstr
connstr = "PROVIDER=SQLNCLI;DATA SOURCE="&Sql_Server&";UID="&Sql_User&";PWD="&Sql_Pass&";DATABASE="&Sql_Data
set Conn = server.createobject("ADODB.connection")
Conn.open connstr
if err then
response.write err.discription
Err.Clear
conn.close
set conn=nothing
Response.Write "数据库连接出错,请检查连接字符串。"
Response.End
end if
%>

回答4:

<%
Set conn=Server.CreateObject("ADODB.Connection")
conn.open "Provider=Microsoft.Jet.OLEDB.4.0;"&"Data Source="&Server.MapPath("数据库名.mdb")
%>
你可以下载YIDACMS
来参考一下 人家的连接方式就行了

回答5:

<%
Set conn=Server.CreateObject("ADODB.Connection")
conn.open "Provider=Microsoft.Jet.OLEDB.4.0;"&"Data Source="&Server.MapPath("数据库名.mdb")
%>