五种DSN的使用方法

  第一种 - 这种方法用在ACCESS中最多 
strconn = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("aspfree.mdb") 
set conn = server.createobject("adodb.connection") 
conn.open strconn 

  第二种-这种方法用在SQL SERVER中多 
strconn = "Driver={SQL Server};Description=sqldemo;SERVER=127.0.0.1;UID=LoginID;PWD=Password;DATABASE=Database_Name 
set conn = server.createobject("adodb.connection") 
conn.open strconn 

  第三种 
strconn="Driver={MicrosoftAccessDriver(*.mdb)};DBQ=F:\Inetpub\wwwroot\somedir\db1.mdb;DefaultDir=f:\Inetpub\wwwroot\somedir;uid=LoginID;pwd=Password;DriverId=25;FIL=MSAccess;" set conn = server.createobject("adodb.connection") 
conn.open strconn 

  第四种运用系统数据源 
The following uses a Data Source Name: 

set conn = server.createobject("adodb.connection") 
conn.open "Example" 
This is created in the Control Panel using the 32 bit ODBC Driver. If you dont know how to setup here is a perfect example on ActiveServerPages.com (click here to find how to create System and File DSNs! 

  第五种运用ODBC数据源,前提是你必须在控制面板的ODBC中设置数据源 
set rs = server.createobject("adodb.recordset") 
rs.open "tblname", "DSNName", 3, 3 

文章评级:★★★★★☆☆☆☆ 发表者:{佚名(127.0.0.*)} 3-29 [ 0]

 分享到:
 
 
我是:
本站注册用户
用户名: 密码:
非本站注册用户
我来评论:

评论字数在2000字以内。评论即可得2分,评论被采用后,根据评级可得到相应的积分和智慧果。
比如:评论评级为5,可得50分和5个智慧果。

 

 
 
 
 
 
 
































 

© 版权所有  2001-2024 知识网站
Copyright (C) 2001-2024 allzhishi.com All rights reserved
联系我们 — 电话:15973023232  微信:zhishizaixian  ICP备案号:湘ICP备08003211号-4