⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ado连接数据库字符串大全.mht

📁 ADO连接数据库字符串大全
💻 MHT
📖 第 1 页 / 共 5 页
字号:
Source=20
              Administrator" program <BR>found in your computer's =
Control Panel=20
              (or Administrative Tools menu in Windows 2000).<BR>Make =
sure to=20
              create a SYSTEM DSN (not a USER DSN) when using ASP. =
<BR>Note: You=20
              can also create the DSN via VB code.</P>
              <P>2) Then use the following connection string - with your =
own DSN=20
              name of course.=A1=A1 ;-)</P>
              <P>ODBC - DSN <BR>=A1=A1 <BR>oConn.Open "DSN=3DAdvWorks;" =
&amp; _=20
              <BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 =
"Uid=3DAdmin;" &amp; _ =
<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 "Pwd=3D;</P>
              <P><BR>You can also create and use a File DSN. Then use =
the=20
              following ADO Connection string:</P>
              <P>ODBC - File DSN <BR>=A1=A1 <BR>oConn.Open=20
              "FILEDSN=3Dc:\somepath\mydb.dsn;" &amp; _ =
<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 =
"Uid=3DAdmin;"=20
              &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 =
"Pwd=3D;"</P>
              <P>For more information, see: About ODBC data sources and =
<BR>How=20
              to Use File DSNs and DSN-less Connections</P>
              <P>Note: The problem with DSN is that Users can (and will) =
modify=20
              them (or delete by mistake), <BR>then your program won't =
work so=20
              well... So it's better to use a DSN-Less or OLE DB =
Provider=20
              <BR>connection string with a Trusted Connection if =
possible! </P>
              <P><BR>ODBC DSN-Less Connections<BR>ODBC Driver for AS/400 =
<BR>=A1=A1=20
              <BR>oConn.Open "Driver=3D{Client Access ODBC Driver =
(32-bit)};"=20
              &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 =
"System=3DmyAS400;" &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=20
              "Uid=3DmyUsername;" &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 =
"Pwd=3DmyPassword;"</P>
              <P>For more information, see:=A1=A1 A Fast Path to AS/400 =
Client/Server=20
              </P>
              <P><BR>ODBC Driver for Access <BR>=A1=A1 <BR>For Standard =
Security:</P>
              <P>oConn.Open "Driver=3D{Microsoft Access Driver =
(*.mdb)};" &amp; _=20
              <BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 =
"Dbq=3Dc:\somepath\mydb.mdb;" &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=20
              "Uid=3DAdmin;" &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 =
"Pwd=3D;"</P>
              <P>If you are using a Workgroup (System database):</P>
              <P>oConn.Open "Driver=3D{Microsoft Access Driver =
(*.mdb)};" &amp; _=20
              <BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 =
"Dbq=3Dc:\somepath\mydb.mdb;" &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=20
              "SystemDB=3Dc:\somepath\mydb.mdw;", =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 "admin", =
""</P>
              <P>If MDB is located on a network share:</P>
              <P>oConn.Open "Driver=3D{Microsoft Access Driver =
(*.mdb)};" &amp;=20
              =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 =
"Dbq=3D\\myServer\myShare\myPath\myDb.mdb;"</P>
              <P>For more information, see: Microsoft Access Driver =
Programming=20
              Considerations</P>
              <P><BR>ODBC Driver for dBASE <BR>=A1=A1 <BR>oConn.Open=20
              "Driver=3D{Microsoft dBASE Driver (*.dbf)};" &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=20
              "DriverID=3D277;" &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 =
"Dbq=3Dc:\somepath;"</P>
              <P>Note: Specify the filename in the SQL statement. For=20
              example:<BR>=A1=A1=A1=A1=A1=A1=A1=A1 oRs.Open "Select * =
From user.dbf", oConn, ,=20
              ,adCmdText</P>
              <P>Note: MDAC 2.1 (or greater) requires the Borland =
Database=20
              Engine (BDE) to update dBase DBF files. (Q238431).</P>
              <P>For more information, see: dBASE Driver Programming=20
              Considerations</P>
              <P><BR>ODBC Driver for Excel <BR>=A1=A1 <BR>oConn.Open=20
              "Driver=3D{Microsoft Excel Driver (*.xls)};" &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=20
              "DriverId=3D790;" &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=20
              "Dbq=3Dc:\somepath\mySpreadsheet.xls;" &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=20
              "DefaultDir=3Dc:\somepath;" </P>
              <P>For more information, see: Microsoft Excel Driver =
Programming=20
              Considerations</P>
              <P><BR>ODBC Driver for MySQL (via MyODBC) <BR>=A1=A1 =
<BR>To connect to=20
              a local database</P>
              <P>oConn.Open "Driver=3D{mySQL};" &amp; _ =
<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=20
              "Server=3DMyServerName;" &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 =
"Option=3D16834;" &amp;=20
              =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 =
"Database=3Dmydb;"</P>
              <P>To connect to a remote database</P>
              <P>oConn.Open "Driver=3D{mySQL};" &amp; _ =
<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=20
              "Server=3Ddb1.database.com;" &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 =
"Port=3D3306;" &amp;=20
              =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 =
"Option=3D131072;" &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 "Stmt=3D;"=20
              &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 =
"Database=3Dmydb;" &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=20
              "Uid=3DmyUsername;" &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 =
"Pwd=3DmyPassword;"</P>
              <P>For more information, see: Programs Known to Work with=20
              MyODBC</P>
              <P><BR>ODBC Driver for Oracle <BR>=A1=A1 <BR>For the =
current Oracle=20
              ODBC Driver from Microsoft:</P>
              <P>oConn.Open "Driver=3D{Microsoft ODBC for Oracle};" =
&amp;=20
              =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 =
"Server=3DOracleServer.world;" &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=20
              "Uid=3DmyUsername;" &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 =
"Pwd=3DmyPassword;"</P>
              <P>For the older Oracle ODBC Driver from Microsoft:</P>
              <P>oConn.Open "Driver=3D{Microsoft ODBC Driver for =
Oracle};" &amp;=20
              =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 =
"ConnectString=3DOracleServer.world;" &amp;=20
              =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 =
"Uid=3DmyUsername;" &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=20
              "Pwd=3DmyPassword;"</P>
              <P>For more information, see: Connection String Format and =

              Attributes</P>
              <P><BR>ODBC Driver for Paradox <BR>=A1=A1 <BR>oConn.Open=20
              "Driver=3D{Microsoft Paradox Driver (*.db)};" &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=20
              "DriverID=3D538;" &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 =
"Fil=3DParadox 5.X;" &amp;=20
              =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 =
"DefaultDir=3Dc:\dbpath\;" &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=20
              "Dbq=3Dc:\dbpath\;" &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 =
"CollatingSequence=3DASCII;"=20
              </P>
              <P>Note: MDAC 2.1 (or greater) requires the Borland =
Database=20
              Engine (BDE) to update Paradox ISAM fDBF files. =
(Q230126).</P>
              <P>For more information, see: Paradox Driver Programming=20
              Considerations</P>
              <P><BR>ODBC Driver for SQL Server <BR>=A1=A1 <BR>For =
Standard=20
              Security:</P>
              <P>oConn.Open "Driver=3D{SQL Server};" &amp; _ =
<BR>=A1=A1=A1=A1=A1=A1 =A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=20
              "Server=3DMyServerName;" &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=20
              "Database=3DmyDatabaseName;" &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 =
"Uid=3DmyUsername;"=20
              &amp; _<BR>=A1=A1=A1=A1 =
=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 "Pwd=3DmyPassword;"</P>
              <P>For Trusted Connection security:</P>
              <P>oConn.Open "Driver=3D{SQL Server};" &amp; _ =
<BR>=A1=A1=A1=A1=A1=A1 =A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=20
              "Server=3DMyServerName;" &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=20
              "Database=3DmyDatabaseName;" &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 "Uid=3D;" =
&amp;=20
              _<BR>=A1=A1=A1=A1 =A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 =
"Pwd=3D;"</P>
              <P>' or </P>
              <P>oConn.Open "Driver=3D{SQL Server};" &amp; _ =
<BR>=A1=A1=A1=A1=A1=A1 =A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=20
              "Server=3DMyServerName;" &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=20
              "Database=3DmyDatabaseName;" &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=20
              "Trusted_Connection=3Dyes;"</P>
              <P>To Prompt user for username and password</P>
              <P>oConn.Properties("Prompt") =3D =
adPromptAlways<BR>oConn.Open=20
              "Driver=3D{SQL Server};" &amp; _ <BR>=A1=A1=A1=A1=A1=A1 =
=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=20
              "Server=3DMyServerName;" &amp; _ <BR>=A1=A1=A1=A1=A1=A1 =
=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=20
              "DataBase=3DmyDatabaseName;"<BR>=A1=A1=A1=A1 </P>
              <P>For more information, see: SQLDriverConnect (ODBC)</P>
              <P><BR>ODBC Driver for Sybase <BR>=A1=A1 <BR>If using the =
Sybase System=20
              11 ODBC Driver:</P>
              <P>oConn.Open "Driver=3D{SYBASE SYSTEM 11};" &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=20
              "Srvr=3DmyServerName;" &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 =
"Uid=3DmyUsername;" &amp;=20
              _<BR>=A1=A1=A1=A1 =A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 =
"Pwd=3DmyPassword;"</P>
              <P>If using the Intersolv 3.10 Sybase ODBC Driver:</P>
              <P>oConn.Open "Driver=3D{INTERSOLV 3.10 32-BIT Sybase};" =
&amp;=20
              =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 =
"Srvr=3DmyServerName;" &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=20
              "Uid=3DmyUsername;" &amp; _<BR>=A1=A1=A1=A1 =
=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 "Pwd=3DmyPassword;"</P>
              <P>For more information, see: Sybase System 10 ODBC Driver =

              Reference Guide</P>
              <P><BR>ODBC Driver for Sybase SQL Anywhere <BR>=A1=A1 =
<BR>oConn.Open=20
              "ODBC; Driver=3DSybase SQL Anywhere 5.0;" &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=20
              "DefaultDir=3Dc:\dbpath\;" &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=20
              "Dbf=3Dc:\sqlany50\mydb.db;" &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 =
"Uid=3DmyUsername;"=20
              &amp; _<BR>=A1=A1=A1=A1 =
=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 =
"Pwd=3DmyPassword;"<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=
=A1=20
"Dsn=3D"""";"</P>
              <P>Note: Including the DSN tag with a null string is =
absolutely=20
              critical or else you get the dreaded -7778 error.</P>
              <P>For more information, see: Sybase SQL Anywhere User =
Guide</P>
              <P><BR>ODBC Driver for Teradata <BR>=A1=A1 <BR>oConn.Open=20
              "Provider=3DTeradata;" &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 =
"DBCName=3DMyDbcName;"=20
              &amp; _ =
<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 =
"Database=3DMyDatabaseName;" &amp; _=20
              <BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 =
"Uid=3DmyUsername;" &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=20
              "Pwd=3DmyPassword;"</P>
              <P>For more information, see Teradata ODBC Driver</P>
              <P><BR>ODBC Driver for Text <BR>=A1=A1 <BR>oConn.Open=20
              "Driver=3D{Microsoft Text Driver (*.txt; *.csv)};" &amp;=20
              =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 =
"Dbq=3Dc:\somepath\;" &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=20
              "Extensions=3Dasc,csv,tab,txt;" &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 "Persist=20
              Security Info=3DFalse"</P>
              <P>Note: Specify the filename in the SQL statement. For=20
              example:</P>
              <P>oRs.Open "Select * From customer.csv", =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 oConn,=20
              adOpenStatic, adLockReadOnly, adCmdText</P>
              <P><BR>For more information, see: Text File Driver =
Programming=20
              Considerations</P>
              <P><BR>ODBC Driver for Visual FoxPro <BR>=A1=A1 <BR>With a =
database=20
              container:</P>
              <P>oConn.Open "Driver=3D{Microsoft Visual FoxPro Driver};" =
&amp;=20
              =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 =
"SourceType=3DDBC;" &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=20
              "SourceDB=3Dc:\somepath\mySourceDb.dbc;" &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=20
              "Exclusive=3DNo;" </P>
              <P>Without a database container (Free Table =
Directory):</P>
              <P>oConn.Open "Driver=3D{Microsoft Visual FoxPro Driver};" =
&amp;=20
              =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1 =
"SourceType=3DDBF;" &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=20
              "SourceDB=3Dc:\somepath\mySourceDbFolder;" &amp; =
_<BR>=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=A1=20
              "Exclusive=3DNo;" </P>
              <P><BR>For more information, see: Visual FoxPro ODBC =
Driver and=20
              Q165492</P>
              <P></P>
              <P><BR>OLE DB Data Link Connections<BR>Data Link File =
(UDL) <BR>=A1=A1=20
              <BR>For Absolute Path:</P>
              <P>oConn.Open "File =
Name=3Dc:\somepath\myDatabaseName.udl;" </P>
              <P>For Relative Path:</P>
              <P>oConn.Open "File Name=3DmyDatabaseName.udl;"<BR>=A1=A1 =
</P>
              <P>For more information, see: HOWTO: Use Data Link Files =
with=20

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -