Results 1 to 15 of 15

Thread: SOLVED - Problem while opening recordset

  1. #1

    Thread Starter
    Hyperactive Member abhid's Avatar
    Join Date
    Nov 2001
    Location
    3rd rock from the sun
    Posts
    467

    SOLVED - Problem while opening recordset

    I am opening ADO.recordset object with following query

    SELECT E.empName,E.basic,E.current,S.increament,S.dateOfInc FROM employeeMaster E,empSalary S WHERE S.empCode = E.empCode

    But it is giving me error like
    "Method 'Open' of object '_Recordset' failed"
    I have checked that recordset is declared and set and query is also working.
    Please help!
    Last edited by abhid; Dec 19th, 2001 at 02:17 AM.

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Do you have a valid connection?

  3. #3

    Thread Starter
    Hyperactive Member abhid's Avatar
    Join Date
    Nov 2001
    Location
    3rd rock from the sun
    Posts
    467
    of course i do..
    Other recordsets are working fine.

  4. #4
    PowerPoster Beacon's Avatar
    Join Date
    Jan 2001
    Location
    Pub Floor
    Posts
    3,188
    ADODB OR ADODC?

    VB Code:
    1. SELECT E.empName,E.basic,E.current,S.increament,S.dateOfInc FROM employeeMaster E,empSalary S WHERE S.empCode = E.empCode

    empSalary S
    Is that meant to be a space?

    Do you just want all the fields?

    Else:
    VB Code:
    1. SELECT E.empName & E.basic & E.current & S.increament & S.dateOfInc FROM employeeMaster E & empSalary S WHERE S.empCode = E.empCode

  5. #5

    Thread Starter
    Hyperactive Member abhid's Avatar
    Join Date
    Nov 2001
    Location
    3rd rock from the sun
    Posts
    467
    its ADODB.
    about 'empSalary S'. Yes it is space.
    i am using S as alias to empSalary table.
    VB Code:
    1. SELECT E.empName,E.basic,E.current,S.increament,S.dateOfInc FROM employeeMaster E,empSalary S WHERE S.empCode = E.empCode
    this query is working properly in SQL view for MSAcces. It is returing expected no. of rows.
    I checked with a simple query like 'select * from empsalary'.
    It opened the recordset properly.
    Problem is the query mentione above is not working with recordset.
    What it could be?
    Thanks for the efforts.

  6. #6
    PowerPoster
    Join Date
    Nov 2001
    Location
    Trying to reach and stay in the cloud
    Posts
    2,089

    hi

    Pls. paste ur code - just before the open method - I feel there lies the prob.

  7. #7

    Thread Starter
    Hyperactive Member abhid's Avatar
    Join Date
    Nov 2001
    Location
    3rd rock from the sun
    Posts
    467
    it is
    VB Code:
    1. Private Sub setSalaryData()
    2. Set rsNavigateSalaryData = New Recordset
    3. strQuery = "SELECT E.empName,E.basic,E.current,S.increament,"_
    4.   & "S.dateOfInc FROM employeeMaster E,empSalary S WHERE " _
    5.   & "S.empCode = E.empCode"
    6.   rsNavigateSalaryData.Open strQuery,conn, adOpenKeyset, adLockOptimistic
    7. End Sub

  8. #8
    PowerPoster Beacon's Avatar
    Join Date
    Jan 2001
    Location
    Pub Floor
    Posts
    3,188
    Try:
    VB Code:
    1. Private Sub setSalaryData()
    2. Set rsNavigateSalaryData = New ADODB.Recordset
    3. strQuery = "SELECT E.empName,E.basic,E.current,S.increament,"_
    4.   & "S.dateOfInc FROM employeeMaster E,empSalary S WHERE " _
    5.   & "S.empCode = E.empCode"
    6.   rsNavigateSalaryData.Open strQuery,conn, adOpenKeyset, adLockOptimistic, adcmdtext
    7. End Sub

  9. #9
    PowerPoster
    Join Date
    Nov 2001
    Location
    Trying to reach and stay in the cloud
    Posts
    2,089
    Just a check :

    Is conn your connection object GLOBAL?

  10. #10

    Thread Starter
    Hyperactive Member abhid's Avatar
    Join Date
    Nov 2001
    Location
    3rd rock from the sun
    Posts
    467
    thanks Beacon but it still has the same problem.
    and yes veryjonny, my conn object is global.

  11. #11
    PowerPoster
    Join Date
    Nov 2001
    Location
    Trying to reach and stay in the cloud
    Posts
    2,089
    Everthing looks okay .

    Cant figure what could be wrong.

    Just two suggestions :

    1)Check after removing the cursorlocation,locktype and the cmdText thing.

    2) Just change the query - use one table instead and check.

  12. #12

    Thread Starter
    Hyperactive Member abhid's Avatar
    Join Date
    Nov 2001
    Location
    3rd rock from the sun
    Posts
    467
    i am really frustrated
    may be i should try another query.
    I am working on it...
    Thanks guys for your help.

  13. #13

    Thread Starter
    Hyperactive Member abhid's Avatar
    Join Date
    Nov 2001
    Location
    3rd rock from the sun
    Posts
    467
    hey guys i solved it. The query goes like
    VB Code:
    1. SELECT employeeMaster.empName, empSalary.increament, empSalary.dateOfInc
    2. FROM employeeMaster INNER JOIN empSalary ON employeeMaster.empcode = empSalary.empCode
    3. WHERE (([employeeMaster].[empcode]=[empsalary].[empcode]))

  14. #14
    PowerPoster Beacon's Avatar
    Join Date
    Jan 2001
    Location
    Pub Floor
    Posts
    3,188
    I still reckon your sql's wrong!

    VB Code:
    1. Private Sub setSalaryData()
    2. Set rsNavigateSalaryData = New ADODB.Recordset
    3. strQuery = "SELECT E.empName,E.basic,E.current,S.increament,"_
    4.   & "S.dateOfInc FROM employeeMaster E & empSalary S WHERE " _
    5.   & "S.[empCode] = E.[empCode] ;"
    6.   rsNavigateSalaryData.Open strQuery,conn, adOpenKeyset, adLockPessimistic, adcmdtext
    7. End Sub

    Changed the lock just in case!

    S and E are tables correct?
    I still dont like that FROM bit though? Which ones are the tables?

  15. #15
    PowerPoster Beacon's Avatar
    Join Date
    Jan 2001
    Location
    Pub Floor
    Posts
    3,188
    Oh well good!
    We'd get there enventually!

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