CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Jul 1999
    Posts
    8

    Stored Procedure

    I want to call a SQL stored procedure from VB app. i have to pass parameters to
    it. everytinhg worked fine. There is a message in the strored procedure if
    the member was added like 'Member added'. when i execute this direclty i
    saw this message. But how can i see this message without writing any code in
    my application?

    Thanks in advance,

    Hima









  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: Stored Procedure

    given this SP
    create proc lahtestpr
    as
    print "hello,world"

    you can call it like this (without parameter)

    de.lahtestpr




    to get the contents of the print statement, inspect

    de.Connection1.Errors(0).Description



    it contains "hello,world".
    an error is not raised.


  3. #3
    Guest

    Re: Stored Procedure

    Thanks for the response. What is 'de' in you example?.


  4. #4
    Join Date
    May 1999
    Posts
    3,332

    Re: Stored Procedure

    the name of the dataenvironment object (by default: DataEnvironment1, but I am a lazy)


  5. #5
    Join Date
    Jul 1999
    Posts
    8

    Re: Stored Procedure

    Lothar,

    I got an error when i execute line
    de.connection1.errors(0).description
    error is "invalid use of property"
    my connection object is connection1,data environment designer is de.
    also is it possible to get the print messages in the stored procedure using command object (without using data environment designer)?


    Hima



  6. #6
    Join Date
    May 1999
    Posts
    3,332

    Re: Stored Procedure

    you didn't post your code, but if you code really looks like this

    de.connection1.errors(0).description

    it doesn't work, because you are accessing a property. Use it as a RHS as in

    msgbox de.....
    or store it in a variable.

    It doesn't matter whether you use a data environment or not.
    The errors collection can be accessed from any connection object.


  7. #7
    Join Date
    Jul 1999
    Posts
    8

    Re: Stored Procedure

    Lothar,

    I did not write any code. In a new project I added data environment designer. For a connection object I specified everything. Then added a command object and for database object (general tab) I specified stored procedure and for object name “my stored procedure name” (addadult). And in the parameter tab I supplied values for all my parameters. When it prompt me to execute or not, I click yes.

    I added a command button I just put code like this
    Msgbox dataenvironment1.connection1.errors(0).description

    Now I got the message
    Error# 3265
    “ADO could not find the object in the collection corresponding to the name or ordinal reference requested by the application”

    do I have to write any code?

    Thank you very much for your time.

    Hima.



  8. #8
    Join Date
    May 1999
    Posts
    3,332

    Re: Stored Procedure

    >do I have to write any code?
    Unfortunately, yes :-)
    That's the bad thing about programming :-)

    you need to execute your SP as in
    dataenvironment1.addadult



    this should execute your SP. If it takes any parameters, pass its values.
    then write

    msgbox ...description





  9. #9
    Join Date
    Jul 1999
    Posts
    8

    Re: Stored Procedure

    It worked. But not the way I was looking for. When I tried with dataenvironment1.addadult , it did not work. I got error “member not found” . so I tried with the code below.

    DataEnvironment1.Command1 "Joe", "D", "Bernal", "Lake st", "Madison st", "Chicago", "66666", “(206)000000"
    MsgBox DataEnvironment1.Connection1.Errors(0).Number

    I got the message
    [Microsoft][ODBC SQL server driver][SQL server]

    And the row is added. But I want the message ‘Member Added’, which is in my stored procedure. Is it possible?

    Thanks,

    Hima



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