Results 1 to 7 of 7

Thread: Stored Procedures

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2000
    Location
    London, UK
    Posts
    137
    Hi all,


    Just a question on Stored Procedures. I am new to VB and to SQL, I have to add some error handling to some stored procedures. They are all Select procedures that are passed varibles from VB. They do not return anything.

    I just want to learn how report any errors (if any) to the vb app and display them to the user.

    Is there any one out there that can help????


    Thanks in advance
    Rocks,
    join me in the platinum

  2. #2
    Hyperactive Member cajsoft's Avatar
    Join Date
    Aug 2000
    Location
    Glasgow, Scotland
    Posts
    295
    Can you expand on this..? what error handeling are you coding into your stored procedure?

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2000
    Location
    London, UK
    Posts
    137

    Stored Procedures

    Hi,

    What I would like to do is to check if the statement has been processed, and where statements use Varibles, I would like to check if they have been passed, are not null.

    If you like I can mail you a stored procedure that I am working on.....


    Regards,

    Rocks
    join me in the platinum

  4. #4
    Hyperactive Member cajsoft's Avatar
    Join Date
    Aug 2000
    Location
    Glasgow, Scotland
    Posts
    295
    I use a stored procedure, and check the results are not null by using this statement below, using a UserConnection

    Code:
    Dim rd as rdoresult
    If IsNull(rd!fieldname)Then
           blah de blah
    End if
    The ISNull check the returned data is not NULL.

    Craig.

  5. #5
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    Many ways..

    In the stored proc
    (after the select)

    IF @@ERROR <> 0
    goto MyError

    return (0) -- Success


    MyError:
    return(1) -- Failure

    or any error value you want


    Now in your VB

    you can check for these values


    That's just one way...

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Sep 2000
    Location
    London, UK
    Posts
    137

    Wink Store Proc

    lafor.

    I managed to get that far what I would like to lnow is how to Pull the error info out of the store proc into VB...


    any advice???


    Cheers mate
    join me in the platinum

  7. #7
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    ....

    When an error occurs the global var

    Err is automatically populated with the necessary info
    including err number and description

    if in your VB, you have

    OnError goto CHrisjk (at the top of your proc)


    then

    Chrisjk:
    MsgBox "Sorry! Error '" & Err.Description '& " 'While Executing this stored proc name here "

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