Results 1 to 12 of 12

Thread: Open of object recordset failed

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2006
    Posts
    977

    Open of object recordset failed

    Hi

    When I execute this query:
    rs6.Open SQL, cn, adOpenKeyset, adLockPessimistic

    the following message occurs:
    "Open of object recordset Failed"

    I am using Access database

    What's wrong?

    Thanks

  2. #2
    Hyperactive Member
    Join Date
    Mar 2006
    Posts
    266

    Re: Open of object recordset failed

    how u have declared the rs6 ?

  3. #3
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Open of object recordset failed

    Most probably you are using a reserved keyword in your query, like DATE, NAME, etc. Try to wrap the Column names in Square Brackets.

    If that doesn't help then please show us what is in SQL variable?
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  4. #4
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: Open of object recordset failed

    Show the code surounding that statement...

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2006
    Posts
    977

    Re: Open of object recordset failed

    The SQl expression is

    VB Code:
    1. SQL = "Select * from test inner Join Client on test.ClientID=Client.ClientID"
    2. SQL = SQL & " inner Join Contact on test.ContactID=Contact.ContactID"
    3. SQL = SQL & " inner Join Event on test.EventID=Event.EventID"
    4. SQL = SQL & " inner Join Interval on test.IntID=Interval.IntID"
    5. SQL = SQL & " inner Join Satellite on test.SatelliteID=Satellite.SatelliteID"
    6. SQL = SQL & " inner Join Origin on test.OriginID=Origin.OriginID"
    7. SQL = SQL & " inner Join Destination on test.DestinationID=Destination.DestinationID"
    8. SQL = SQL & " inner Join Guest on test.GuestID=Guest.GuestID where BID=12"

    Please help me

  6. #6
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: Open of object recordset failed

    You need to show more that just the SQL statement. More code...

    What is rs6 defined as? Did you open the database? etc...

    We cannot see anything from one or two statements...

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2006
    Posts
    977

    Re: Open of object recordset failed

    Well I used Rs6 to open another SQl and it worked,so i am pretty sure that the error is from the SQL string

    What's wrong in my SQL string?
    thanks

  8. #8
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: Open of object recordset failed

    If you are go tell us what is wrong, then why ask the question...

    Did you test the SQL statement in native Access?
    Last edited by randem; Aug 3rd, 2006 at 05:56 AM.

  9. #9
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Open of object recordset failed

    Quote Originally Posted by engnouna
    The SQl expression is

    VB Code:
    1. SQL = "Select * from test inner Join Client on test.ClientID=Client.ClientID"
    2. SQL = SQL & " inner Join Contact on test.ContactID=Contact.ContactID"
    3. SQL = SQL & " inner Join Event on test.EventID=Event.EventID"
    4. SQL = SQL & " inner Join Interval on test.IntID=Interval.IntID"
    5. SQL = SQL & " inner Join Satellite on test.SatelliteID=Satellite.SatelliteID"
    6. SQL = SQL & " inner Join Origin on test.OriginID=Origin.OriginID"
    7. SQL = SQL & " inner Join Destination on test.DestinationID=Destination.DestinationID"
    8. SQL = SQL & " inner Join Guest on test.GuestID=Guest.GuestID where BID=12"

    Please help me
    Try wrapping up your columns/Table names in square brackets [] in your SQL and the problem will be resolved. I guess it is Event/Test /Interval that is creating this problem.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  10. #10

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2006
    Posts
    977

    Re: Open of object recordset failed

    Well i tried this

    VB Code:
    1. SQL = "Select * from [test]"
    2. SQL = SQL & " inner Join [Client] on [test].[ClientID]=[Client].[ClientID]"
    3. SQL = SQL & " inner Join [Contact] on [test].[ContactID]=[Contact].[ContactID]"
    4. SQL = SQL & " inner Join [Event] on [test].[EventID]=[Event].[EventID]"
    5. SQL = SQL & " inner Join [Interval] on [test].[IntID]=[Interval].[IntID]"
    6. SQL = SQL & " inner Join [Satellite] on [test].[SatelliteID]=[Satellite].[SatelliteID]"
    7. SQL = SQL & " inner Join [Origin] on [test].[OriginID]=[Origin].[OriginID]"
    8. SQL = SQL & " inner Join [Destination] on [test].[DestinationID]=[Destination].[DestinationID]"
    9. SQL = SQL & " inner Join [Guest] on [test].[GuestID]=[Guest].[GuestID] where [test].[BID]=12"

    But it returned "Syntax error missing operator"

    I am desperate,what's wrong with my SQL statement?

    Thanks

  11. #11
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Open of object recordset failed

    Shouldn't it be
    VB Code:
    1. SQL = "Select [TEST].* from [test]"
    And is BID a numeric field?
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  12. #12
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Open of object recordset failed

    Quote Originally Posted by Shuja Ali
    I guess it is Event/Test /Interval that is creating this problem.
    I would agree that those names are dubious, and should be enclosed.

    I'm not sure about the others (Contact/Origin/..), so it's safest to do them anyway.

    Quote Originally Posted by Randem
    Did you test the SQL statement in native Access?
    I would assume not, as Access tends to not like joins without its own special format of brackets, which are something like this:
    Code:
    FROM ((t1 
           INNER JOIN t2 ON ...)
           INNER JOIN t3 ON ... )
           INNER JOIN t4 ON ...

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