PDA

View Full Version : Error while connecting to Oracle database from excel macro



rockybalboa
04-07-2017, 02:23 AM
Hi,

Earlier i had a separate login credentials to access database. The macro used to work fine then.

Now my database access is LDAP authenticated (i.e my windows login id and pass is now my database login credentials). But now the below macro code is not working.

Error MSG "Runitime error '-2147217843(80040e4d)' invalid username/password; logon denied"

Could you please help me with this? I am using my windows login credentials here
Sub GetData()Dim rst As New ADODB.Recordset
Dim cnn As New ADODB.Connection
Dim tran_key
Dim strSql
Dim fname As String
Dim a As Integer
Dim b As Integer
Dim c As Integer
Dim d As Integer
Dim strID, strPW As String
strID = ThisWorkbook.Sheets("Input").Range("M3").Value
strPW = ThisWorkbook.Sheets("Input").Range("M4").Value


b = 0
c = 0


conn = "UID=" & strID & ";PWD=" & strPW & ";DRIVER={Microsoft ODBC for Oracle};SERVER=prd.world;"
With cnn
.ConnectionString = conn
.CursorLocation = adUseClient
.Open
End WithThanks,
Kirtesh

mancubus
04-07-2017, 05:40 AM
i have never used an oracle database nor had a computer on which oracle installed, but a quick search in Google gave me this.

https://hoopercharles.wordpress.com/2009/12/02/retrieve-data-to-excel-with-a-macro-using-ado/