+ Reply to Thread
Results 1 to 3 of 3

Returning a Value into Excel from SQL ADO connection

Hybrid View

  1. #1
    Stopher
    Guest

    Returning a Value into Excel from SQL ADO connection

    Hi All first post.

    I am currently having a problem returning a value into a cell in excel
    2000

    I understand the ADO connection, and have checked my sqlSTR in query
    analyser.

    I use the following to dump to a cell.

    Set rcset = New ADODB.Recordset
    rcset.Open sqlstr, dbmain, adOpenKeyset, adLockOptimistic
    Sheets("Sizing").Range("b19").CopyFromRecordset rcset

    What I have used this to dump the whole record set out, but the sqlstr
    I am using only has a specific value in it. I am currently getting
    #value in my cell, and am wondering if the value coming out of the ADO
    dump is actually text.

    Is there anyway to specify the value coming out of the rcset is a value
    and not text?


  2. #2
    Bob Phillips
    Guest

    Re: Returning a Value into Excel from SQL ADO connection

    I would doubt that getting a text value would show as #VALUE in a cell,. it
    would just show the value.

    Why don't you add some logic in the code to step through the recordset
    rather than copy it, and then debug it

    If Not oRS.EOF Then
    For i = 0 To oRS.fields.Count - 1
    Debug.Print oRS.fields.Item(i).Value
    Next i

    --
    HTH

    Bob Phillips

    (replace somewhere in email address with gmail if mailing direct)

    "Stopher" <[email protected]> wrote in message
    news:[email protected]...
    > Hi All first post.
    >
    > I am currently having a problem returning a value into a cell in excel
    > 2000
    >
    > I understand the ADO connection, and have checked my sqlSTR in query
    > analyser.
    >
    > I use the following to dump to a cell.
    >
    > Set rcset = New ADODB.Recordset
    > rcset.Open sqlstr, dbmain, adOpenKeyset, adLockOptimistic
    > Sheets("Sizing").Range("b19").CopyFromRecordset rcset
    >
    > What I have used this to dump the whole record set out, but the sqlstr
    > I am using only has a specific value in it. I am currently getting
    > #value in my cell, and am wondering if the value coming out of the ADO
    > dump is actually text.
    >
    > Is there anyway to specify the value coming out of the rcset is a value
    > and not text?
    >




  3. #3
    Stopher
    Guest

    Re: Returning a Value into Excel from SQL ADO connection



    I sorted it out. Instead of referencing a cell in the CopyRecordset I
    recalled the value for the function, so-

    Set rcset = New ADODB.Recordset
    rcset.Open sqlstr, dbmain, adOpenKeyset, adLockOptimistic
    [INSERT FUNCTION HERE].CopyFromRecordset rcset


+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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