📄 ado连接数据库字符串大全(vp,excel,文本,sybase,.net等).htm
字号:
<TBODY>
<TR>
<TD bgColor=#297dff colSpan=2 height=20><FONT color=#ceffff> →
<A href="http://www.aspsky.net/article/index.asp?classid=2"><FONT
color=#ceffff>ASP技术</FONT></A> >> <A
href="http://www.aspsky.net/article/index.asp?classid=2&Nclassid=10"><FONT
color=#ceffff>数据库相关</FONT></A> >>
《ADO连接数据库字符串大全(VP,Excel,文本,Sybase,.NET等)》</FONT></TD></TR>
<TR>
<TD bgColor=#586011 colSpan=2 height=1><SPACER type="block"
width="1"></TD></TR>
<TR>
<TD colSpan=2 height=7></TD></TR>
<TR>
<TD align=middle class=p4
colSpan=2><B>ADO连接数据库字符串大全(VP,Excel,文本,Sybase,.NET等)</B></FONT><BR>2001-11-28 动网先锋
</TD></TR>
<TR>
<TD class=p4 colSpan=2>
<BLOCKQUOTE><BR>This page contains sample ADO connection strings
for ODBC DSN / DSN-Less,<BR>OLE DB Providers, Remote Data Services
(RDS), MS Remote, MS DataShape.
<P></P>
<P>Also included are ADO.NET connection strings for each .NET
Managed Provider <BR>(SQLClient, OLEDB, and ODBC).</P>
<P>These sample connection strings are compiled <BR>by Carl
Prothman, a Microsoft Visual Basic MVP <BR>Enjoy!<BR><BR>
<BR>Table of Contents<BR>ODBC DSN Connections DSN <BR>File
DSN<BR><BR><BR>ODBC DSN-Less Connections ODBC Driver for AS/400
<BR>ODBC Driver for Access <BR>ODBC Driver for dBASE <BR>ODBC
Driver for Excel <BR>ODBC Driver for MySQL <BR>ODBC Driver for
Oracle <BR>ODBC Driver for Paradox <BR>ODBC Driver for SQL Server
<BR>ODBC Driver for Sybase <BR>ODBC Driver for Sybase SQL Anywhere
<BR>ODBC Driver for Text <BR>ODBC Driver for Teradata <BR>ODBC
Driver for Visual FoxPro<BR><BR><BR>OLE DB Data Link Connections
Data Link File (UDL)<BR><BR><BR>OLE DB Data Provider Connections
OLE DB Provider for AS/400 <BR>OLE DB Provider for Active
Directory Service <BR>OLE DB Provider for DB2 <BR>OLD DB Provider
for Internet Publishing <BR>OLE DB Provider for Index Server
<BR>OLE DB Provider for Microsoft Jet <BR>OLE DB Provider for ODBC
Databases <BR>OLE DB Provider for Oracle (From Microsoft) <BR>OLE
DB Provider for Oracle (From Oracle) <BR>OLE DB Provider for
Simple Provider <BR>OLE DB Provider for SQL Server
<BR><BR><BR>Remote Data Service (RDS) Connections RDS Data Control
- Connect Property <BR>RDS Data Control - URL
Property<BR><BR><BR>ADO URL Connections ADO
Recordset<BR><BR><BR>MS Remote Provider Connections MS Remote -
Access (Jet) <BR>MS Remote - SQL Server<BR><BR><BR>Data Shape
Provider Connections MS DataShape - SQL Server<BR><BR><BR>.NET
Managed Provider Connections SQL Client .NET Managed Provider
(System.Data.SqlClient) <BR>OLE DB .NET Managed Provider
(System.Data.OleDb) <BR>ODBC .NET Managed Provider
(System.Data.ODBC) <BR><BR><BR> <BR></P>
<P>ODBC DSN Connections<BR>Using an ODBC DSN (Data Source Name) is
a two step process. </P>
<P>1) You must first create the DSN via the "ODBC Data Source
Administrator" program <BR>found in your computer's Control Panel
(or Administrative Tools menu in Windows 2000).<BR>Make sure to
create a SYSTEM DSN (not a USER DSN) when using ASP. <BR>Note: You
can also create the DSN via VB code.</P>
<P>2) Then use the following connection string - with your own DSN
name of course. ;-)</P>
<P>ODBC - DSN <BR> <BR>oConn.Open "DSN=AdvWorks;" & _
<BR> "Uid=Admin;" & _ <BR> "Pwd=;<BR></P>
<P>You can also create and use a File DSN. Then use the following
ADO Connection string:</P>
<P>ODBC - File DSN <BR> <BR>oConn.Open
"FILEDSN=c:\somepath\mydb.dsn;" & _ <BR> "Uid=Admin;"
& _<BR> "Pwd=;"</P>
<P>For more information, see: About ODBC data sources and <BR>How
to Use File DSNs and DSN-less Connections</P>
<P>Note: The problem with DSN is that Users can (and will) modify
them (or delete by mistake), <BR>then your program won't work so
well... So it's better to use a DSN-Less or OLE DB Provider
<BR>connection string with a Trusted Connection if possible! </P>
<P></P>
<P>ODBC DSN-Less Connections<BR>ODBC Driver for AS/400 <BR>
<BR>oConn.Open "Driver={Client Access ODBC Driver (32-bit)};"
& _<BR> "System=myAS400;" & _<BR>
"Uid=myUsername;" & _<BR> "Pwd=myPassword;"</P>
<P>For more information, see: A Fast Path to AS/400 Client/Server
</P>
<P></P>
<P>ODBC Driver for Access <BR> <BR>For Standard Security:</P>
<P>oConn.Open "Driver={Microsoft Access Driver (*.mdb)};" & _
<BR> "Dbq=c:\somepath\mydb.mdb;" & _<BR>
"Uid=Admin;" & _<BR> "Pwd=;"</P>
<P>If you are using a Workgroup (System database):</P>
<P>oConn.Open "Driver={Microsoft Access Driver (*.mdb)};" & _
<BR> "Dbq=c:\somepath\mydb.mdb;" & _<BR>
"SystemDB=c:\somepath\mydb.mdw;", _<BR> "admin", ""</P>
<P>If MDB is located on a network share:</P>
<P>oConn.Open "Driver={Microsoft Access Driver (*.mdb)};" &
_<BR> "Dbq=\\myServer\myShare\myPath\myDb.mdb;"</P>
<P>For more information, see: Microsoft Access Driver Programming
Considerations</P>
<P></P>
<P>ODBC Driver for dBASE <BR> <BR>oConn.Open "Driver={Microsoft
dBASE Driver (*.dbf)};" & _<BR> "DriverID=277;" &
_<BR> "Dbq=c:\somepath;"</P>
<P>Note: Specify the filename in the SQL statement. For
example:<BR> oRs.Open "Select * From user.dbf", oConn, ,
,adCmdText</P>
<P>Note: MDAC 2.1 (or greater) requires the Borland Database
Engine (BDE) to update dBase DBF files. (Q238431).</P>
<P>For more information, see: dBASE Driver Programming
Considerations</P>
<P></P>
<P>ODBC Driver for Excel <BR> <BR>oConn.Open "Driver={Microsoft
Excel Driver (*.xls)};" & _<BR> "DriverId=790;" &
_<BR> "Dbq=c:\somepath\mySpreadsheet.xls;" &
_<BR> "DefaultDir=c:\somepath;" </P>
<P>For more information, see: Microsoft Excel Driver Programming
Considerations</P>
<P></P>
<P>ODBC Driver for MySQL (via MyODBC) <BR> <BR>To connect to a
local database</P>
<P>oConn.Open "Driver={mySQL};" & _ <BR>
"Server=MyServerName;" & _<BR> "Option=16834;" &
_<BR> "Database=mydb;"</P>
<P>To connect to a remote database</P>
<P>oConn.Open "Driver={mySQL};" & _ <BR>
"Server=db1.database.com;" & _<BR> "Port=3306;" &
_<BR> "Option=131072;" & _<BR> "Stmt=;"
& _<BR> "Database=mydb;" & _<BR>
"Uid=myUsername;" & _<BR> "Pwd=myPassword;"</P>
<P>For more information, see: Programs Known to Work with
MyODBC</P>
<P></P>
<P>ODBC Driver for Oracle <BR> <BR>For the current Oracle ODBC
Driver from Microsoft:</P>
<P>oConn.Open "Driver={Microsoft ODBC for Oracle};" &
_<BR> "Server=OracleServer.world;" & _<BR>
"Uid=myUsername;" & _<BR> "Pwd=myPassword;"</P>
<P>For the older Oracle ODBC Driver from Microsoft:</P>
<P>oConn.Open "Driver={Microsoft ODBC Driver for Oracle};" &
_<BR> "ConnectString=OracleServer.world;" &
_<BR> "Uid=myUsername;" & _<BR>
"Pwd=myPassword;"</P>
<P>For more information, see: Connection String Format and
Attributes</P>
<P></P>
<P>ODBC Driver for Paradox <BR> <BR>oConn.Open "Driver={Microsoft
Paradox Driver (*.db)};" & _<BR> "DriverID=538;"
& _<BR> "Fil=Paradox 5.X;" & _<BR>
"DefaultDir=c:\dbpath\;" & _<BR> "Dbq=c:\dbpath\;"
& _<BR> "CollatingSequence=ASCII;" </P>
<P>Note: MDAC 2.1 (or greater) requires the Borland Database
Engine (BDE) to update Paradox ISAM fDBF files. (Q230126).</P>
<P>For more information, see: Paradox Driver Programming
Considerations</P>
<P></P>
<P>ODBC Driver for SQL Server <BR> <BR>For Standard Security:</P>
<P>oConn.Open "Driver={SQL Server};" & _ <BR>
"Server=MyServerName;" & _<BR>
"Database=myDatabaseName;" & _<BR> "Uid=myUsername;"
& _<BR> "Pwd=myPassword;"</P>
<P>For Trusted Connection security:</P>
<P>oConn.Open "Driver={SQL Server};" & _ <BR>
"Server=MyServerName;" & _<BR>
"Database=myDatabaseName;" & _<BR> "Uid=;" &
_<BR> "Pwd=;"</P>
<P>' or </P>
<P>oConn.Open "Driver={SQL Server};" & _ <BR>
"Server=MyServerName;" & _<BR>
"Database=myDatabaseName;" & _<BR>
"Trusted_Connection=yes;"</P>
<P>To Prompt user for username and password</P>
<P>oConn.Properties("Prompt") = adPromptAlways<BR>oConn.Open
"Driver={SQL Server};" & _ <BR>
"Server=MyServerName;" & _ <BR>
"DataBase=myDatabaseName;"<BR> </P>
<P>For more information, see: SQLDriverConnect (ODBC)</P>
<P></P>
<P>ODBC Driver for Sybase <BR> <BR>If using the Sybase System 11
ODBC Driver:</P>
<P>oConn.Open "Driver={SYBASE SYSTEM 11};" & _<BR>
"Srvr=myServerName;" & _<BR> "Uid=myUsername;" &
_<BR> "Pwd=myPassword;"</P>
<P>If using the Intersolv 3.10 Sybase ODBC Driver:</P>
<P>oConn.Open "Driver={INTERSOLV 3.10 32-BIT Sybase};" &
_<BR> "Srvr=myServerName;" & _<BR>
"Uid=myUsername;" & _<BR> "Pwd=myPassword;"</P>
<P>For more information, see: Sybase System 10 ODBC Driver
Reference Guide</P>
<P></P>
<P>ODBC Driver for Sybase SQL Anywhere <BR> <BR>oConn.Open "ODBC;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -