Results 1 to 5 of 5

Thread: [ODBC Driver Manager] Data source name not found and no default driver specified

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2013
    Posts
    6

    [ODBC Driver Manager] Data source name not found and no default driver specified

    I am trying to display oracle DB into DataGrid and facing some problem

    Code:
    Private Sub Command2_Click()
        Dim oconn As ADOconnect
        Dim rs As Recordset
        Dim strSQL As String
        
        strSQL = "SELECT * FROM ZZZJUNKPERSON"
        Set oconn = New ADOconnect
        Set rs = New ADODB.Recordset
        oconn.Open "ODBC;DSN=SSSS;UID=SSSSS;PWD=SSSSS;DATABASE=SSSSS"
        rs.CursorType = adOpenStatic
        rs.CursorLocation = adUseClient
        rs.LockType = adLockOptimistic
        rs.Open strSQL, oconn, , , adCmdText
        Set DataGrid1.DataSource = rs
             
    End Sub
    when I compile the code I get error.
    I am new to VB.
    Last edited by hoho46; Mar 7th, 2013 at 04:55 AM.

  2. #2
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: ERROR: method or data member not found

    What is 'ADOconnect' ?

    Normally you'd define a Reference to Microsoft Active Data Objects and use 'ADODB.Connection'. Also you need to initialise the RecordSet before using it in the same way you do for the connection.
    Code:
    Private Sub Command2_Click()
        Dim oconn As ADODB.Connection
        Dim rs As ADODB.Recordset
        Dim strSQL As String
        
        strSQL = "SELECT * FROM ZZZJUNKPERSON"
        Set oconn = New ADODB.Connection
        Set rs = New ADODB.RecordSet
        oconn.Open "Provider=msdaora;ODBC;DSN=SSSS;UID=SSSSS;PWD=SSSSS;DATABASE=SSSSS"
        rs.CursorType = adOpenStatic
        rs.CursorLocation = adUseClient
        rs.LockType = adLockOptimistic
        rs.Open strSQL, oconn, , , adCmdText
        Set DataGrid1.DataSource = rs
             
    End Sub

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2013
    Posts
    6

    Re: ERROR: method or data member not found

    Thanks for the reply, I am new to this. I just follow some tutorial by googling.
    I still get the runtime error message: ORA-12560: TNS: protocol adapter error
    What is that mean?

  4. #4
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: ERROR: method or data member not found

    Probably that your connection string is incorrect. try
    Code:
    oconn.Open "Provider=msdaora;Data Source=MyOracleDB;User Id=myUsername;Password=myPassword;"
    where 'MyOracleDB' is your Oracle Database,'myUsername' is your Oracle Username and 'myPassword' is your Oracle Password

  5. #5

    Thread Starter
    New Member
    Join Date
    Feb 2013
    Posts
    6

    Re: ERROR: method or data member not found

    then i got this error message. very Sorry
    ORA-12154: TNS:could not resolve the connect identifier specified

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width