Results 1 to 11 of 11

Thread: linked server, adodc vs recordset

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Location
    London
    Posts
    99
    I've set up a linked server to the Index Service. Using the debugger in SQL i've tested my sproc and it returns the filename & size of various files.

    On the UI side, if I attach an adodc to the sproc and a datacombo to the adodc i get a recordset returned. But, if I attempt to do this through a recordset I get -1 records returned.

    Any ideas?
    VB6 Enterprise sp5, SQL Server2000

  2. #2
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008
    How are you attempting to get the data from the sp? I would suspect it is the way in which you are calling the sp and how you are using the parameters collection. Could you post the code and maybe the sp itself?

    Cheers,

    P.
    Not nearly so tired now...

    Haven't been around much so be gentle...

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Location
    London
    Posts
    99
    Here's the sproc

    CREATE proc spDocumentsInHoldingPool
    as
    SELECT *
    FROM OpenQuery(roverholdingarea,
    'SELECT FileName, DocAuthor,Size
    FROM SCOPE('' "e:\ftptesting\rover\holdingpool" '')
    WHERE FileName LIKE ''%.%''
    order by FileName '
    )

    I've tried every permutation of opening a recordset known to Man. ie passing in a string as a connection, trying to use a command object etc

    Whats really bugging me is that I can pull back the records using an adodc control then Set recordset=adodc1.recordset and this works!

    VB6 Enterprise sp5, SQL Server2000

  4. #4
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008
    Can you show me some of the code you are using to get the data back? I just want to see how you are approaching it.

    There really shouldn't be a problem.

    Cheers,

    P.
    Not nearly so tired now...

    Haven't been around much so be gentle...

  5. #5

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Location
    London
    Posts
    99
    Private Sub Command3_Click()
    Dim con As ADODB.Connection
    Dim rs3 = New ADODB.Recordset
    Set con = New ADODB.Connection
    Set rs3 = New ADODB.Recordset

    con.ConnectionString = "Provider=SQLOLEDB.1;" & _
    "Initial Catalog=Rover;Data Source=xxxx.xxxx.xxxx.xxxx;" & _
    "Password=xxxxxxxxxxxx;User ID=RoverAdministration"
    con.CursorLocation = adUseClient
    con.Open

    Set cmd.ActiveConnection = con
    cmd.CommandType = adCmdStoredProc
    cmd.CommandText = "spDocumentsInHoldingPool"
    rs3.Open "exec spdocumentsinholdingpool", con, , adCmdStoredProc

    Set DataCombo3.RowSource = rs3
    DataCombo3.ListField = "filename"

    Debug.Print "rs3 " & rs3.RecordCount

    End Sub


    The above code results in -2147467900 'The command contained one or more errors'.
    VB6 Enterprise sp5, SQL Server2000

  6. #6
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008
    I have never done it that way.

    Try:

    Dim con As ADODB.Connection
    Dim rs3 = New ADODB.Recordset
    Set con = New ADODB.Connection
    Set rs3 = New ADODB.Recordset

    con.ConnectionString = "Provider=SQLOLEDB.1;" & _
    "Initial Catalog=Rover;Data Source=xxxx.xxxx.xxxx.xxxx;" &_
    "Password=xxxxxxxxxxxx;User ID=RoverAdministration"
    con.CursorLocation = adUseClient
    con.Open


    cmd.CommandText = "spDocumentsInHoldingPool"
    cmd.CommandType = adCmdStoredProc
    cmd.Name = "MyLocalSP"
    Set cmd.ActiveConnection = con
    con.MyLocalSP rs3


    Set DataCombo3.RowSource = rs3
    DataCombo3.ListField = "filename"

    My bit is in bold (obviously).

    Let me know if it works for you.

    Cheers,

    P.

    Not nearly so tired now...

    Haven't been around much so be gentle...

  7. #7

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Location
    London
    Posts
    99
    Didn't work I'm afraid.

    error - -2147467900 'The command contained one or more errors'.
    VB6 Enterprise sp5, SQL Server2000

  8. #8
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008
    V. Strange,

    why not try the connection method against a simple SELECT sp, ensure that that works first. This is odd but I have never used OpenQuery in an sp before.

    Cheers,

    P.
    Not nearly so tired now...

    Haven't been around much so be gentle...

  9. #9

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Location
    London
    Posts
    99
    I tried that earlier, it works fine.


    Arrgggghhhhh!
    VB6 Enterprise sp5, SQL Server2000

  10. #10

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Location
    London
    Posts
    99
    Err Oops!

    I hadn't set the linked servers permissions.

    I can now use

    rs.open "exec spxxx",cn

    but I get 0 records returned

    VB6 Enterprise sp5, SQL Server2000

  11. #11
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008
    /slap

    Ok. What about my way of connecting? Does that work? You've got me worried now.

    Cheers,

    P.
    Not nearly so tired now...

    Haven't been around much so be gentle...

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