DBMNG数据库管理与应用

抓住自己最有兴趣的东西,由浅入深,循序渐进地学……
当前位置:首页 > 服务器配置 > IIS&ASP

asp数据库连接代码

<%
'(1)连接ACCESS
'**************************
Set Conn=Server.CreateObject("ADODB.Connection")
    Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("*.mdb")&""
    Conn.Open
  '或者:
 'mdbpath=server.MapPath("*.mdb") 
 'CnnStr = "DBQ=" & mdbpath & ";DRIVER={Microsoft Access Driver (*.mdb)};uid=用户名;pwd=密码" 
  'Conn.Open CnnStr
'**************************
'(2)连接SQLSERVER
'**************************
Set conn=Server.CreateObject("ADODB.Connection")
conn.Open "driver={SQLServer};server=192.168.0.1;uid=用户名;pwd=密码;database=数据库名"
'**************************
'(3)连接MYSQL
'**************************
Set conn = Server.CreateObject("ADODB.Connection") 
    conn.Open "DSN=MYSQL5;uid=用户名;PWD=密码" '数据源名
'或者:
'Set conn=Server.CreateObject("ADODB.Connection")
'conn.Open "driver={MySQL ODBC 3.51 Driver};DATABASE=数据库名;SERVER=localhost;UID=用户名;PASSWORD=密码;PORT=3306;OPTION=3;"
'**************************
'(4)连接ORACLE
Set  Conn=Server.CreateObject("ADODB.Connection")  
StrConn="Driver={Microsoft ODBC for Oracle};Server=OracleServer.world;Uid=myUsername;Pwd=myPassword;"  
Conn.Open  strConn  
'(5)连接FOXPRO
Set Conn = Server.CreateObject( "ADODB.Connection")
Conn.Open "Driver={Microsoft Visual FoxPro Driver};SourceType=DBF;SourceDB=数据库路径;Exclusive=No" 
%>
本站文章内容,部分来自于互联网,若侵犯了您的权益,请致邮件chuanghui423#sohu.com(请将#换为@)联系,我们会尽快核实后删除。
Copyright © 2006-2023 DBMNG.COM All Rights Reserved. Powered by DEVSOARTECH            豫ICP备11002312号-2

豫公网安备 41010502002439号