Conectando-se ao Oracle

Conectando-se ao Oracle



Use o código abaixo para se conectar ao Banco de Dados Oracle:
Sub Ora_Connection()  
Dim rs As ADODB.Recordset  Dim query As String  Set con = New ADODB.Connection  Set rs = New ADODB.Recordset  '---- Replace below highlighted names with the corresponding values  strCon = "Driver={Microsoft ODBC for Oracle}; " & _  "CONNECTSTRING=(DESCRIPTION=" & _  "(ADDRESS=(PROTOCOL=TCP)" & _  "(HOST=Your Host Name)(PORT=Port Number))" & _  "(CONNECT_DATA=(SID=SID of your Database))); uid=User ID; pwd=Password;"  '---  Open   the above connection string.  con.Open (strCon)  '---  Now connection is open and you can use queries to execute them.   '---  It will be open till you close the connection  
End Sub  
Dim con As ADODB.Connection  

Oracle Connection String with Service:


Sub Ora_Connection()  
Dim con As ADODB.Connection  Dim rs As ADODB.Recordset  Dim query As String  Set con = New ADODB.Connection  Set rs = New ADODB.Recordset  '---  Replace below highlighted names with the corresponding values  strCon = "Driver={Microsoft ODBC for Oracle}; " & _  "CONNECTSTRING=(DESCRIPTION=" & _  "(ADDRESS=(PROTOCOL=TCP)" & _  "(HOST=Your Host Name)(PORT=Enter Port Number))" & _  "(CONNECT_DATA=(SERVICE_NAME=database))); uid=Enter User ID; pwd=Enter Password;"  '---  Open the above connection string.  con.Open (strCon)  '---  Now connection is open and you can use queries to execute them.  '---  It will be open till you close the connection  
End Sub 



Envie seus comentários e sugestões e compartilhe este artigo!

brazilsalesforceeffectiveness@gmail.com

✔ Brazil SFE®✔ Brazil SFE®´s Facebook´s Profile  Google+   Author´s Professional Profile  ✔ Brazil SFE®´s Pinterest       ✔ Brazil SFE®´s Tweets

Nenhum comentário:

Postar um comentário

diHITT - Notícias