Click to See Complete Forum and Search --> : Stored Procedure


hima
July 26th, 1999, 03:58 PM
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

Lothar Haensler
July 27th, 1999, 02:25 AM
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.

August 1st, 1999, 05:05 PM
Thanks for the response. What is 'de' in you example?.

Lothar Haensler
August 2nd, 1999, 02:15 AM
the name of the dataenvironment object (by default: DataEnvironment1, but I am a lazy)

hima
August 3rd, 1999, 11:45 AM
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

Lothar Haensler
August 4th, 1999, 02:07 AM
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.

hima
August 4th, 1999, 09:46 AM
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.

Lothar Haensler
August 4th, 1999, 09:49 AM
>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

hima
August 4th, 1999, 10:42 AM
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