+ Reply to Thread
Results 1 to 13 of 13

VBA - Problem getting data from Oracle server using SQL query with Recordset

  1. #1
    Registered User
    Join Date
    07-16-2012
    Location
    Ireland
    MS-Off Ver
    Excel 2003
    Posts
    6

    VBA - Problem getting data from Oracle server using SQL query with Recordset

    Hi,

    Newbie to form. I'm using ADODB and recordset with SQL to get data from an Oracle server. I can get the data but for some reason it's only pulling the first field from the database. I've been using a watch on rst.fields to see what i'm retrieving. Any ideas?

    Please Login or Register  to view this content.
    Last edited by Cutter; 07-16-2012 at 09:16 AM. Reason: Added code tags

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: VBA - Problem getting data from Oracle server using SQL query with Recordset

    is rst.fields.count = 1? how many fields are in the table?
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  3. #3
    Registered User
    Join Date
    07-16-2012
    Location
    Ireland
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: VBA - Problem getting data from Oracle server using SQL query with Recordset

    So it's a table with about 60 columns and hundreds of rows. The query returned the correct rst.field.name but the rst.field.value is only returned for the first row, and there should be hundreds.

    I want to further filter this down after but if this first step doesn't work I can't go any further.

  4. #4
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: VBA - Problem getting data from Oracle server using SQL query with Recordset

    you will only see the value for the current record in the watch window

  5. #5
    Registered User
    Join Date
    07-16-2012
    Location
    Ireland
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: VBA - Problem getting data from Oracle server using SQL query with Recordset

    Really? But fields.count only equals the number of columns and there only seems to be one row of data

  6. #6
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: VBA - Problem getting data from Oracle server using SQL query with Recordset

    yes, really. that is how recordsets work :-)

    fields.count should be the number of fields not number of records. you view the other records by moving through the recordset or outputting the data-that's not really what the watch window is meant for.

  7. #7
    Registered User
    Join Date
    07-16-2012
    Location
    Ireland
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: VBA - Problem getting data from Oracle server using SQL query with Recordset

    Ok Thanks. What is the best way to gather the data?

  8. #8
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: VBA - Problem getting data from Oracle server using SQL query with Recordset

    what do you want to do with it?

  9. #9
    Registered User
    Join Date
    07-16-2012
    Location
    Ireland
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: VBA - Problem getting data from Oracle server using SQL query with Recordset

    So the moment I just want to see data for a few rows. Say the first three rows

  10. #10
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: VBA - Problem getting data from Oracle server using SQL query with Recordset

    you can copy it to a sheet using code like this
    Please Login or Register  to view this content.

  11. #11
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: VBA - Problem getting data from Oracle server using SQL query with Recordset

    Hi Dapos, and welcome to the forum. Sorry to interrupt, but please notice that I have added code tags to your original post. The forum rules require their use so please keep that in mind when showing code in any future posts. Thanks.

    Here's the rule:

    RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

  12. #12
    Registered User
    Join Date
    07-16-2012
    Location
    Ireland
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: VBA - Problem getting data from Oracle server using SQL query with Recordset

    Hi,

    Apologies for not using the code tags. Will use from now on.

    JosephP, thanks for your help. Stupid on my part, I assumed I would be able to see everything from the watch window.

    That worked a treat now. I used the following

    Please Login or Register  to view this content.
    Thanks again,

    Dapos.

  13. #13
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: VBA - Problem getting data from Oracle server using SQL query with Recordset

    It appears, based on your last post, that your thread can now be marked as SOLVED. I'll do that for you now but please remember to do it yourself in your future threads. Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1