惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

宝玉的分享
宝玉的分享
NISL@THU
NISL@THU
E
Exploit-DB.com RSS Feed
L
LINUX DO - 热门话题
L
Lohrmann on Cybersecurity
K
Kaspersky official blog
Project Zero
Project Zero
Cisco Talos Blog
Cisco Talos Blog
T
The Exploit Database - CXSecurity.com
P
Palo Alto Networks Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
S
Schneier on Security
G
GRAHAM CLULEY
The Hacker News
The Hacker News
T
Threat Research - Cisco Blogs
Scott Helme
Scott Helme
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
P
Privacy & Cybersecurity Law Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Cyberwarzone
Cyberwarzone
C
CERT Recently Published Vulnerability Notes
T
Tor Project blog
AWS News Blog
AWS News Blog
Simon Willison's Weblog
Simon Willison's Weblog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
爱范儿
爱范儿
P
Privacy International News Feed
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
S
Securelist
G
Google Developers Blog
The Last Watchdog
The Last Watchdog
Google Online Security Blog
Google Online Security Blog
美团技术团队
F
Fortinet All Blogs
小众软件
小众软件
Recorded Future
Recorded Future
V
Visual Studio Blog
B
Blog RSS Feed
H
Help Net Security
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Google DeepMind News
Google DeepMind News
Blog — PlanetScale
Blog — PlanetScale
博客园 - 聂微东
Stack Overflow Blog
Stack Overflow Blog
Martin Fowler
Martin Fowler
Latest news
Latest news
Spread Privacy
Spread Privacy
H
Heimdal Security Blog

博客园 - 易来

Linux不能上网问题 怎么都没人留下评论啊 终于完成博客大"搬"家 JAVA系列学习 虚函数的作用 某培训机构的JAVA课程安排 简单程序--征解! [转]一个高级黑客给黑客同胞们的匿名信 C++中的I/O流的相关函数 类成员的初始化问题 QQ失而复得 电影 ASP连接数据库的5种方法 软件设计师考试 你谈恋爱的目的是什么? 五一 如何开发右脑 2006年9月8号 俞敏洪:奋斗成就新东方
asp连接数据库的方法(全)
易来 · 2006-11-08 · via 博客园 - 易来

ADO相关知识
在ASP中,用来存取数据库的对象统称ADO(Active Data Objects),主要含有三种对象:Connection、Recordset 、Command
Connection:负责打开或连接数据
Recordset:负责存取数据表
Command:负责对数据库执行行动查询命令
连接各数据库的驱动程序
连接各数据库可以使用驱动程序(OLEDB),也可以使用数据源(ODBC),相对来说使用OLEDB较为方便、简单。
ODBC链接(红色加粗部分为数据库类型,右方为相关连接方式)

access "Driver={microsoft access driver(*.mdb)};dbq=*.mdb;uid=admin;pwd=pass;"

dBase "Driver={microsoft dbase driver(*.dbf)};driverid=277;dbq=------------;"

Oracle "Driver={microsoft odbc for oracle};server=oraclesever.world;uid=admin;pwd=pass;"

MSSQL server "Driver={sql server};server=servername;database=dbname;uid=sa;pwd=pass;"

MS text "Driver={microsoft text driver(*.txt; *.csv)};dbq=-----;extensions=asc,csv,tab,txt;Persist SecurityInfo=false;"

Visual Foxpro "Driver={microsoft Visual Foxpro driver};sourcetype=DBC;sourceDB=*.dbc;Exclusive=No;"

MySQL "Driver={mysql};database=yourdatabase;uid=username;pwd=yourpassword;option=16386;"

OLEDB链接
access "Provider=microsoft.jet.oledb.4.0;data source=your_database_path;user id=admin;password=pass;"

Oracle "Provider=OraOLEDB.Oracle;data source=dbname;user id=admin;password=pass;"

MS SQL Server "Provider=SQLOLEDB;data source=machinename;initial catalog=dbname;userid=sa;password=pass;"

MS text "Provider=microsof.jet.oledb.4.0;data source=your_path;Extended Properties'text;FMT=Delimited'"

在Asp中连接Access的数据库相关代码可以写为:
Dim db,conn,connstr
db="data/hezepolice.mdb"
Set conn = Server.CreateObject("ADODB.Connection")

connstr="DBQ="+server.mappath("db")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"

'采用Oledb方式
'connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db)

'字符串写法的不同
'connstr="Driver={microsoft access driver (*.mdb)};DBQ=" & Server.MapPath(db)

'采用先行建立的Dsn进行连接
'connstr="dsn=hezepolice;"
conn.open connstr
以下是数据库采用sqlserver的时候Asp建立数据连接常用的代码方式之一

Set conn=Server.CreateObject("ADODB.Connection")
on error resume next
connstr="Provider=SQLOLEDB;Password=***;Persist Security Info=True;User ID=sa;Initial Catalog=msdb;Data Source=localhost;Connect Timeout=15"
conn.Open connstr
微软建议在连接Access数据库使用下面的方法:
dim conn
set conn = server.createobject("adodb.connection")
conn.open = "provider=microsoft.jet.oledb.4.0;" & "data source = " & server.mappath("data.mdb")