|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
缺点:安全性不是太差了,还行,只要你充分利用系统自带的工具;唯一缺点就是执行效率慢,如何进行网站优化以后,效果会比较好。 上面将复杂引见一下几种ADO毗连体例:ODBC DSN,ODBC DSN-Less,
OLE DB Provider,和"MS Remote" Provider.
1。ODBC DSN毗连
I.DSN
oConn.Open "DSN=AdvWorks;" & _
"UID=Admin;" & _
"PWD=;"
注重:从MDAC2.1入手下手就不克不及够在利用如许的体例了,就是只把DSN文件名放在ConnectString中
你必需同时利用DSN,UID,PWD标记。例以下面的体例在MDAC 2.1中将会失足:
oConn.Open "AdvWorks"
II.File DSN
oConn.Open "FILEDSN=\somepath\mydb.dsn;" & _
"UID=Admin;" & _
"PWD=;"
III.ODBC DSN-Less Connections
a)ODBC Text Driver
oConn.Open _
"Driver={Microsoft Text Driver (*.txt; *.csv)};" & _
"Dbq=\somepath\;" & _
"Extensions=asc,csv,tab,txt;" & _
"Persist Security Info=False"
注重:需求在SQL语句中指定利用到的文件名。例如:
oRs.Open "Select * From customer.csv", _
oConn, adOpenStatic, adLockReadOnly, adCmdText
b)ODBC Driver for Access
i)通俗平安形式:
oConn.Open _
"Driver={Microsoft Access Driver (*.mdb)};" & _
"Dbq=\somepath\mydb.mdb;" & _
"Uid=Admin;" & _
"Pwd=;"
ii)假如利用了System database:
oConn.Open _
"Driver={Microsoft Access Driver (*.mdb)};" & _
"Dbq=\somepath\mydb.mdb;" & _
"SystemDB=\somepath\mydb.mdw;", _
"admin", ""
c)ODBC Driver for SQL Server
i)通俗平安形式
oConn.Open "Driver={SQL Server};" & _
"Server=carl2;" & _
"Database=pubs;" & _
"Uid=sa;" & _
"Pwd=;"
ii)利用信赖平安形式:
oConn.Open "Driver={SQL Server};" & _
"Server=carl2;" & _
"Database=pubs;" & _
"Uid=;" & _
"Pwd=;"
注重:要利用空白的Uid和Pwd
d)ODBC Driver for Oracle
i)利用现有的Oracle ODBC Driver from Microsoft:
oConn.Open _
"Driver={Microsoft ODBC for Oracle};" & _
"Server=OracleServer.world;" & _
"Uid=demo;" & _
"Pwd=demo;"
ii)利用老版本的Oracle ODBC Driver from Microsoft:
oConn.Open _
"Driver={Microsoft ODBC Driver for Oracle};" & _
"ConnectString=OracleServer.world;" & _
"Uid=demo;" & _
"Pwd=demo;"
IIII)利用微软的OLE DB Data Link Connections体例Data Link File (UDL)
a)利用相对途径
oConn.Open "File Name=\somepath\pubs.udl;"
b)利用绝对途径
oConn.Open "File Name=pubs.udl;"
V)OLE DB Provider Connections体例
a)OLE DB Provider for ODBC Databases
i)Access (Jet):
oConn.Open _
"Provider=MSDASQL;" & _
"Driver={Microsoft Access Driver (*.mdb)};" & _
"Dbq=\somepath\mydb.mdb;" & _
"Uid=Admin;" & _
"Pwd=;"
ii)SQL Server:
oConn.Open _
"Provider=MSDASQL;" & _
"Driver={SQL Server};" & _
"Server=carl2;" & _
"Database=pubs;" & _
"Uid=sa;" & _
"Pwd=;"
b)OLE DB Provider for Microsoft Jet (Access)
i)通俗平安形式:
oConn.Open _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=\somepath\mydb.mdb;" & _
"User Id=admin;" & _
"Password=;"
ii)假如利用了System database:
oConn.Open _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=\somepath\mydb.mdb;" & _
"Jet OLEDB:System Database=system.mdw;", _
"admin", ""
注重:当利用OLE DB Provider4.0版本是,需求把MDB和MDW文件转换成4.0的数据库格局
iii)假如MDB需求一个数据库暗码的话:
oConn.Open _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=\somepath\mydb.mdb;" & _
"Jet OLEDB:Database Password=MyDbPassword;", _
"admin", ""
c)OLE DB Provider for Excel Spreadsheet:
oConn.Open _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=\somepath\expenses.xls;" & _
"Extended Properties=""Excel 8.0;HDR=Yes;"";"
注重: "HDR=Yes"暗示在第一行中是行题目,在provider中将不把第一行包含入recordset中
d)OLE DB Provider for SQL Server
i)通俗平安形式:
oConn.Open "Provider=sqloledb;" & _
"Network Library=DBMSSOCN;" & _
"Data Source=carl2;" & _
"Initial Catalog=pubs;" & _
"User Id=sa;" & _
"Password=;"
ii)利用信赖平安形式:
oConn.Open "Provider=sqloledb;" & _
Network Library=DBMSSOCN;" & _
"Data Source=carl2;" & _
"Initial Catalog=pubs;" & _
"Trusted_Connection=yes;"
注重:"Network Library=DBMSSOCN"声明OLE DB利用TCP/IP替换Named Pipes.
e)OLE DB Provider for Oracle
oConn.Open "Provider=msdaora;" & _
"Data Source=OracleServer.world;" & _
"User Id=sa;" & _
"Password=;"
(VI)Remote OLE DB Provider Connections体例(就是我一向在研讨的RDS体例哦,呵呵。):
a)MS Remote - Access (Jet)
i)ODBC DSN:
oConn.Open "Remote Server=http://carl2;" & _
"Remote Provider=MSDASQL;" & _
"DSN=AdvWorks;" & _
"Uid=admin" & _
"Pwd=;"
ii)OLE DB Provider:
oConn.Open "Provider=MS Remote;" & _
"Remote Server=http://carl2;" & _
"Remote Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=\somepath\mydb.mdb;", _
"admin", ""
iii)OLE DB Provider自界说事务对象
oConn.Open "Provider=MS Remote;" & _
"Remote Server=http://carl2;" & _
"Handler=MSDFMAP.Handler;" & _
"Data Source=MyAdvworksOLEDBConnectTag;"
b)MS Remote - SQL Server
i)ODBC DSN:
oConn.Open "Remote Server=http://carl2;" & _
"Remote Provider=MSDASQL;" & _
"Network Library=DBMSSOCN;" & _
"DSN=Pubs;" & _
"Uid=sa" & _
"Pwd=;"
ii)OLE DB Provider
oConn.Open "Provider=MS Remote;" & _
"Remote Server=http://carl2;" & _
"Remote Provider=SQLOLEDB;" & _
"Network Library=DBMSSOCN;" & _
"Data Source=carl2;" & _
"Initial Catalog=pubs;" & _
"User ID=sa;" & _
"Password=;"
大家可以自己去看一看.可以说看得想呕吐.以前有次下了个动网来看.里面连基本内置函数的保护措施(函数没防御性)都没有.难怪经常补这个补那个了.可能现在.NET版会好点吧 |
|