Essa aqui, eu achei na net.. e achei legal salientar:
====================
ODBC DNS Connections
=====================
DNS
Conn.Open "DSN=SampleDB;Uid=Admin;Pwd=;"
File DNS
Conn.Open "FILEDSN=\\path\\mydb.dsn;Uid=Admin;Pwd=;"
ODBC DNS-Less Connections
ODBC Driver for AS/400
Conn.Open "Driver={Client Access ODBC Driver (32-bit)}; System=myAS400;Uid=myUsername;Pwd=myPassword;"
ODBC Driver for dBASE
Conn.Open "Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;Dbq=\\somepath;"
rs.Open "SELECT * FROM USER.DBF", Conn
ODBC Driver for MS Access
Conn.Open "Driver={Microsoft Access Driver (*.mdb)};" & _
"Dbq=\\path\\mydb.mdb;Uid=Admin;Pwd=;"
Using a Workgroup (System database)
Conn.Open "Driver={Microsoft Access Driver (*.mdb)};" & _
"Dbq=\\path\\mydb.mdb;SystemDB=\\somepath\\mydb.mdw;", "admin",""
ODBC Driver for MS Excel
Conn.Open "Driver={Microsoft Excel Driver (*.xls)};DriverId=790;" & _
"Dbq=\\somepath\\Sheet1.xls;DefaultDir=\\somepath;"
ODBC Driver for MySQL (MyODBC)
Conn.Open "Driver={mySQL};Server=MyServerName;Option=16834;Database=mydb;"
ODBC Driver for Oracle
Conn.Open "Driver={Microsoft ODBC for Oracle};Server=OracleServer.world;" & _
"Uid=myUsername;Pwd=myPassword;"
ODBC Driver for Paradox
Conn.Open "Driver={Microsoft Paradox Driver (*.db)};DriverID=538;Fil=Paradox 5.X;" & _
"DefaultDir=c:\\dbpath\\;Dbq=c:\\dbpath\\;CollatingSequence=ASCII;"
ODBC Driver for SQL Server
Conn.Open "Driver={SQL Server};Server=MyServerName;Database=myDatabaseName;" & _
"Uid=myUsername;Pwd=myPassword
For trusted connection
Conn.Open "Driver={SQL Server};Server=MyServerName;Database=myDatabaseName;" & _
"Trusted_Connection=yes;"
To Prompt user for username and password
Conn.Properties("Prompt") = adPromptAlways
Conn.Open "Driver={SQL Server}; Server=ServerName; DataBase=DatabaseName;"
ODBC Driver for Sybase
Sybase System 11 ODBC Driver
Conn.Open "Driver={SYBASE SYSTEM 11}; Srvr=myServerName;" & _
"Uid=myUsername; Pwd=myPassword;"
Intersolv 3.10 Sybase ODBC Driver
Conn.Open "Driver={INTERSOLV 3.10 32-BIT Sybase}; Srvr=myServerName;" & _
"Uid=myUsername; Pwd=myPassword;"
ODBC Driver for Sybase SQL Anywhere
Conn.Open "ODBC; Driver=Sybase SQL Anywhere 5.0;" & _
"DefaultDir=c:\\dbpath\\; Dbf=c:\\sqlany50\\mydb.db;" & _
"Uid=myUsername; Pwd=myPassword; Dsn="""";"
ODBC Driver for Text
Conn.Open "Driver={Microsoft Text Driver (*.txt; *.csv)};" & _
"Dbq=\\somepath\\; Extensions=asc,csv,tab,txt; Persist Security Info=False"
rs.Open "SELECT * FROM CUSTOMER.CSV", Conn
ODBC Driver for Visual FoxPro
With a database container
Conn.Open "Driver={Microsoft Visual FoxPro Driver}; SourceType=DBC;" & _
"SourceDB=\\somepath\\mySourceDb.dbc; Exclusive=No;"
Without a database container (Free Table Directory)
Conn.Open "Driver={Microsoft Visual FoxPro Driver}; SourceType=DBF;" & _
"SourceDB=\\somepath\\mySourceDbFolder; Exclusive=No;"
============================
OLE DB Provider Connections
============================
OLE DB Provider for AS/400
Conn.Open "Provider=IBMDA400; Data source=myAS400;" & _
"User Id=myUsername; Password=myPassword;"
OLE DB Provider for Active Directory Service
Conn.Open "Provider=ADSDSOObject; User Id=myUsername; Password=myPassword;"
OLE DB Provider for DB2
Conn.Open = "Provider=DB2OLEDB;" & _
"Network Transport Library=TCPIP; Network Address=MyServer;" & _
"Package Collection=MyPackage; Host CCSID=1142; Initial Catalog=MyDB;" & _
"User ID=MyUsername; Password=MyPassword;"
OLE DB Provider for Index Server
Conn.Open "Provider=msidxs; Data source=MyCatalog;"
OLE DB Provider for Internet Publishing
Conn.Open "Provider=MSDAIPP.DSO; Data Source=http://mywebsite/myDir;" & _
"User Id=myUsername; Password=myPassword;"
OLE DB Provider for Microsoft Jet
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=\\somepath\\myDb.mdb;" & _
"User Id=admin; Password=;"
Using a Workgroup (System database)
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=\\somepath\\mydb.mdb;" & _
"Jet OLEDB:System Database=MySystem.mdw;", "admin", ""
MDB has a database password
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=\\somepath\\mydb.mdb;" & _
"Jet OLEDB:Database Password=MyDbPassword;", "admin", ""
Open Excel
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=\\somepath\\Sheet1.xls;" & _
"Extended Properties=""Excel 8.0;HDR=Yes;"";"
OLE DB Provider for ODBC Databases
MS Access (Jet)
Conn.Open "Provider=MSDASQL; Driver={Microsoft Access Driver (*.mdb)};" & _
"Dbq=\\somepath\\mydb.mdb; Uid=myUsername; Pwd=myPassword;"
SQL Server
Conn.Open "Provider=MSDASQL; Driver={SQL Server};" & _
"Server=myServerName; Database=myDatabaseName;" & _
"Uid=myUsername; Pwd=myPassword;"
OLE DB Provider for Oracle
from Microsoft
Conn.Open "Provider=msdaora; Data Source=MyOracleDB;" & _
"User Id=myUsername; Password=myPassword;"
from Oracle
Conn.Open "Provider=OraOLEDB.Oracle; Data Source=MyOracleDB;" & _
"User Id=myUsername; Password=myPassword;"
For a Trusted Connection
Conn.Open "Provider=OraOLEDB.Oracle; Data Source=MyOracleDB; User Id=/; Password=;"
Conn.Open "Provider=OraOLEDB.Oracle; Data Source=MyOracleDB; OSAuthent=1;"
OLE DB Provider for Simple Provider
Conn.Open "Provider=MSDAOSP; Data Source=MSXML2.DSOControl.2.6;"
rs.Open "http://WebServer/VirtualRoot/MyXMLFile.xml", Conn
OLE DB Provider for SQL Server
Conn.Open "Provider=sqloledb; Data Source=ServerName; Initial Catalog=DatabaseName;" & _
"User Id=myUsername; Password=myPassword;"
For a Trusted Connection
Conn.Open "Provider=sqloledb; Data Source=ServerName; Initial Catalog=DatabaseName;" & _
"Integrated Security=SSPI;"
Connect to a "Named Instance" (SQL Server 2000)
Conn.Open "Provider=sqloledb; Data Source=ServerName\\Inst2; Initial Catalog=DatabaseName;" & _
"User Id=myUsername; Password=myPassword;"
Prompt for username and password
Conn.Provider = "sqloledb"
Conn.Properties("Prompt") = adPromptAlways
Conn.Open "Data Source=ServerName; Initial Catalog=DatabaseName;"
To connect via an IP address
Conn.Open "Provider=sqloledb; Network Library=DBMSSOCN;" & _
"Data Source=xxx.xxx.xxx.xxx,1433; Initial Catalog=DatabaseName;" & _
"User ID=myUsername; Password=myPassword;"
==================================
Remote OLE DB Provider Connections
==================================
MS Remote - Access (Jet)
ODBC DSN
Conn.Open "Provider=MS Remote; Remote Server=http://ServerName; Remote Provider=MSDASQL; DSN=AdvWorks; Uid=myUsername; Pwd=myPassword;"
OLE DB Provider
Conn.Open "Provider=MS Remote; Remote Server=http://ServerName; Remote Provider=Microsoft.Jet.OLEDB.4.0; Data Source=\\path\\mydb.mdb;", "admin", ""
MS Remote - SQL Server
ODBC DSN
Conn.Open "Provider=MS Remote; Remote Server=http://server; Remote Provider=MSDASQL; DSN=DatabaseName; Uid=Username; Pwd=Password;"
OLE DB Provider
Conn.Open "Provider=MS Remote; Remote Server=http://ServerName; Remote Provider=SQLOLEDB; Data Source=ServerName; Initial Catalog=DatabaseName; User ID=Username; Password=Password;"
=================================
.NET Managed Provider Connections
=================================
SQL Client .NET Managed Provider (System.Data.SqlClient)
Dim Conn As SqlClient.SqlConnection
Dim ConnStr As String
ConnStr = "Data Source=(local); Initial Catalog=NorthWind; Integrated Security=SSPI; Pooling=True; Min Pool Size=10; Max Pool Size=50; Connection Lifetime=30; Connection Reset=True; Enlist=True;"
Conn = New SqlClient.SqlConnection(ConnStr)
Conn.Open()
OLE DB .NET Managed Provider (System.Data.OleDb)
Dim Conn As OleDb.OleDbConnection
Dim ConnStr As String
ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=nwind.mdb; User ID=Admin; Password=;"
Conn = New OleDb.OleDbConnection(ConnStr)
Conn.Open()
Pergunta
dark0
Essa aqui, eu achei na net.. e achei legal salientar:
Como eu achei na web mesmo, essa dica, continua ali os créditos do autor!
Abraços!
Link para o comentário
Compartilhar em outros sites
1 resposta a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.