Results 1 to 6 of 6

Thread: SQL Query Problem :(

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026

    SQL Query Problem :(

    Ok, I have the following SQL Query in both Access and VB... In access, it pulls two records, just as it should, but in VB when I do a recordset.recordcount, it gives me "-1" and only opens one recordset into my datareport.

    VB Code:
    1. SELECT Company.Name, Company.Address, Company.City,
    2. Company.State, Company.Zip, Company.Telephone, [Units.Number], Units.Price, Units.CustomerNumber,
    3. Customers.Name, Customers.Address, Customers.City,
    4. Customers.State, Customers.Zip, Customers.Telephone,
    5. Customers.Balance, Customers.LastPayment FROM (Company INNER JOIN Units ON Company.Number = Units.Company) INNER
    6. JOIN Customers ON (Units.CustomerNumber =
    7. Customers.Number) AND (Company.Number =
    8. Customers.Company)

    Like I said, It will work in Access, but vb doesn't want to do it...
    oh, btw... I'm invoking it by DB.Execute

    Thanx,
    squirrelly1
    Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Working on Sunday?

    Post all your code.

  3. #3
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    The usual culprit. The cursor location and type do not support the Recordcount property. Try a client side cursor location and/or a static cursor.

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026
    I don't have much choice. I'm supposed to get a beta of this program to my client tomorrow and I still have to get a few reports done... No hard stuff... well, it shouldn't be anyway.

    how do i set the curser location and type when I'm using the .execute method of ADODB? A little code example would help. Thank you...

    Squirrelly1
    Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?

  5. #5
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    You can't set the cursor type with the Execute method of the Connection object but you can set the location. By default this will result in an adOpenStatic cursor type, which is fine. On second thought it may depend on which provider you are using, so you better check or make life easier and use the Recordset.Open method.

    VB Code:
    1. Dim objCon as ADODB.Connection
    2. Dim objRS as ADODB.Recordset
    3.  
    4. Set objCon = New ADODB.Connection
    5. objCon.CursorLocation = adUseClient
    6. objCon.Open "provider=..."
    7. Set objRs = objCon.Execute(strSQL)
    8.  
    9. 'or use the open method instead
    10. Set objRs = New ADODB.Recordset
    11. objRs.CursorLocation = adUseClient
    12.  
    13. objRs.Open strSQL, objCon, adOpenStatic, adLockReadOnly,adCmdText

  6. #6
    Addicted Member
    Join Date
    Jan 2004
    Location
    philippines
    Posts
    245

    Talking

    yeah! that would be the culprit made lots of error because of that one.

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