CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 1999
    Location
    Bolton/England
    Posts
    7

    Stored Procedures

    I have created an ODBC connection 'conPubs',
    and I have successfully managed to use the CreateQueryDef to use a SQL string to extract the info. It says in the documentation that you can substitute this SQL string with a Stored Procedure name. So I wrote a basic stored procedure in SQL Enterprise, added it to the Database, and tried to run this sp name instead of the SQL string from the client. I got an error message 3146 ODBC call failed.
    The stored procedure name is 'pr_vb_test'
    the code is:

    strSQL = "pr_vb_test"
    Set qdfTemp=conPubs.CreateQueryDef("",strSQL)
    Set rsTemp=qdfTemp.Openrecordset

    Can anyone help please?





  2. #2
    Join Date
    Oct 1999
    Posts
    12

    Re: Stored Procedures

    You cannot do what you are trying, I think you have misunderstood the documenation. CreateQueryDef( "", strSQL ) is trying to create a temporary QueryDef and excepts strSQL to be a valid SQL statement which in your case it is not, it's 'pr_vb_test' so the call will fail.

    In fact you do not even need a QueryDef for what you are trying to do. Just open the recordset passing the name of the query like this:

    Dim rsTemp as Recordset
    Set rsTemp = conPubs.OpenRecordSet( "pr_vb_test" )



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

Featured