Results 1 to 7 of 7
  1. #1
    Join Date
    Dec 2016
    Posts
    5

    Answered: Error [DB2/NT64] SQL0204N "DB2ADMIN.ORG" is an undefined name. SQLSTATE=42704

    I am trying to connect DB2 from Excel using ADO Connection string and its giving me error "[DB2/NT64] SQL0204N "DB2ADMIN.ORG" is an undefined name. SQLSTATE=42704"

    Can anyone please help me on this

    Code:
    Sub Import_data_from_db2()
    
    On Error GoTo ERR
    
    Dim rs As ADODB.Recordset
    Dim cnn As ADODB.Connection
    
    Dim sConnString As String
    
    Set rs = New ADODB.Recordset
    Set cnn = New ADODB.Connection
    
    ' create the connection
    sConnString = "Provider=IBMDADB2;Database=Sample;" & _
                  "Hostname=machinename;Protocol=TCPIP;" & _
                  "Port=50000;Uid=db2admin;Pwd=xxxxx;"
    'Open connection
    cnn.Open sConnString
    
    strQry = "SELECT * FROM ORg"
    With rs
        .CursorLocation = adUseClient
        .CursorType = adOpenDynamic
        .LockType = adLockOptimistic
        .Open strQry, cnn
    End With
    
    'paste data
    Sheets(1).Range("A1").CopyFromRecordset rs
    
    'close
    rs.Close
    cnn.Close
    ERR:
    Debug.Print ERR.Description
    End Sub

  2. Best Answer
    Posted by mark.bb

    "
    Quote Originally Posted by sunnyk2057 View Post
    Its Kumar Sunny
    Try this then.
    select * from "Kumar Sunny".org"


  3. #2
    Join Date
    Apr 2012
    Posts
    1,135
    Provided Answers: 25
    Which schema contains table/view "Org" ? Either connect with that userid(schema-name) or qualify the table/view name in the SELECT with the correct schema name. You may also be able to specify a default schema name as a connection property if that name is different from the account used to authenticate.

  4. #3
    Join Date
    Dec 2016
    Posts
    5

    Tried schema name in query

    Quote Originally Posted by db2mor View Post
    Which schema contains table/view "Org" ? Either connect with that userid(schema-name) or qualify the table/view name in the SELECT with the correct schema name. You may also be able to specify a default schema name as a connection property if that name is different from the account used to authenticate.
    I tried to run same query on Data Studio and its not working. Snapshot

    Click image for larger version. 

Name:	sanpshot1.png 
Views:	4 
Size:	41.2 KB 
ID:	17233

    I also tried adding Schema name in query like

    select * from [lastname Firstname].org


    And I have given database access to db2admin. Right click on database -> Manage Privileges

  5. #4
    Join Date
    Jul 2016
    Location
    Moscow
    Posts
    260
    Provided Answers: 39
    What's the result of the following query?
    Code:
    select tabschema from syscat.tables where tabname='ORG'
    Regards,
    Mark.

  6. #5
    Join Date
    Dec 2016
    Posts
    5

    its

    Quote Originally Posted by mark.bb View Post
    What's the result of the following query?
    Code:
    select tabschema from syscat.tables where tabname='ORG'
    Its Kumar Sunny

  7. #6
    Join Date
    Jul 2016
    Location
    Moscow
    Posts
    260
    Provided Answers: 39
    Quote Originally Posted by sunnyk2057 View Post
    Its Kumar Sunny
    Try this then.
    select * from "Kumar Sunny".org
    Regards,
    Mark.

  8. #7
    Join Date
    Dec 2016
    Posts
    5

    Thumbs up Thanks

    Quote Originally Posted by mark.bb View Post
    Try this then.
    select * from "Kumar Sunny".org
    Thanks a lot its working fine

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
  •