以下向大家介绍一下asp连接各种不同数据库的规范,以供参考(使用ADO)
1———连接到access数据库
<%
Set c1 = Server.CreateObject("ADODB.Connection")
P1="Provider=Microsoft.Jet.OLEDB.4.0;"&"Data Source="&Server.MapPath("db1.msb")
c1.Open P1
%>
2———连接到Excel数据库
<%
Set c2 = Server.CreateObject("ADODB.Connection")
P2="Driver={Microsoft Excel Driver(*.xls)};"&"DBQ="&Server.MapPath("Ex1.xls")
c2.Open P2
%>
3———连接到Visual Foxpro数据库
<%
Set c3 = Server.CreateObject("ADODB.Connection")
P3="Driver={Microsoft Visual Foxpro Driver};"&"SourceType=DBC;"&"SourceDB="&Server.MapPath("DBc/s1.dbc")
c3.Open P3
%>
4———连接到SQL Server数据库
<%
Set c4 = Server.CreateObject("ADODB.Connection")
P4="Provider=SQLOLEDB.1;"&"Data Source="&ComputerName&";User ID="&UserId&";Password="&Password&";Initial Catalog="&Db
c4.Open P4
%>
以上如有问题请与我联系,大家一起探讨。
谢谢!!!