|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Store Procedure return values to VB.net appI have a SP that returns a int value as an alias called "returnvalue". I can call the SP fine in my code. conLog = New SqlConnection("Server=localhost;uid=*****;pwd=*****;database=footbet") cmdLog = New SqlCommand("loginStore", conLog) cmdLog.CommandType = CommandType.StoredProcedure cmdLog.Parameters.IndexOf("@InUse") conLog.Open() cmdLog.ExecuteScalar() myMainfrm.Show() conLog.Close() No I can look at my dataAdapter and preview my return value from my store procedure. So I believe the connection is just fine. I just want to be able to send that returnvalue to a text box in my program. So all I need is the output the SP is giving me, and put that value in a textbox. Can anybody point me in the right direction, and let me know what is the best way of doing this? As always, Thank you for your time. Rudy Rudy
Do you mean? \\\ mytextbox.Text = cmdLog.ExecuteScalar() /// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatasqlclientsqlcommandclassexecutescalartopic.asp I hope this helps Cor Rudy,
Here is a slightly better link - http://support.microsoft.com/kb/308049/EN-US/#3 Even though the above would work, you can also do an output parameter from the s/proc. - Sahil Malik http://codebetter.com/blogs/sahil.malik/ Show quoteHide quote "Rudy" <R***@discussions.microsoft.com> wrote in message news:E49229DA-9783-4047-BA07-496A7FDA2A0D@microsoft.com... > Hello All! > > I have a SP that returns a int value as an alias called "returnvalue". I can > call the SP fine in my code. > conLog = New > SqlConnection("Server=localhost;uid=*****;pwd=*****;database=footbet") > cmdLog = New SqlCommand("loginStore", conLog) > > cmdLog.CommandType = CommandType.StoredProcedure > cmdLog.Parameters.IndexOf("@InUse") > conLog.Open() > cmdLog.ExecuteScalar() > myMainfrm.Show() > > conLog.Close() > > No I can look at my dataAdapter and preview my return value from my store > procedure. So I believe the connection is just fine. I just want to be able > to send that returnvalue to a text box in my program. So all I need is the > output the SP is giving me, and put that value in a textbox. > Can anybody point me in the right direction, and let me know what is the > best way of doing this? > > As always, Thank you for your time. > > Rudy The last ADO.NET code sample shows how to return @RETURN_VALUE
http://www.eggheadcafe.com/articles/20030729.asp -- Show quoteHide quote2005 Microsoft MVP C# Robbe Morris http://www.robbemorris.com http://www.learncsharp.net/home/listings.aspx "Rudy" <R***@discussions.microsoft.com> wrote in message news:E49229DA-9783-4047-BA07-496A7FDA2A0D@microsoft.com... > Hello All! > > I have a SP that returns a int value as an alias called "returnvalue". I > can > call the SP fine in my code. > conLog = New > SqlConnection("Server=localhost;uid=*****;pwd=*****;database=footbet") > cmdLog = New SqlCommand("loginStore", conLog) > > cmdLog.CommandType = CommandType.StoredProcedure > cmdLog.Parameters.IndexOf("@InUse") > conLog.Open() > cmdLog.ExecuteScalar() > myMainfrm.Show() > > conLog.Close() > > No I can look at my dataAdapter and preview my return value from my store > procedure. So I believe the connection is just fine. I just want to be > able > to send that returnvalue to a text box in my program. So all I need is the > output the SP is giving me, and put that value in a textbox. > Can anybody point me in the right direction, and let me know what is the > best way of doing this? > > As always, Thank you for your time. > > Rudy Thank you all, you have been very helpful!
I had no idea could be so straight forward. Jeeeze!! Thanks again for your time!!! Rudy Show quoteHide quote "Robbe Morris [C# MVP]" wrote: > The last ADO.NET code sample shows how to return @RETURN_VALUE > > http://www.eggheadcafe.com/articles/20030729.asp > > -- > 2005 Microsoft MVP C# > Robbe Morris > http://www.robbemorris.com > http://www.learncsharp.net/home/listings.aspx > > > > "Rudy" <R***@discussions.microsoft.com> wrote in message > news:E49229DA-9783-4047-BA07-496A7FDA2A0D@microsoft.com... > > Hello All! > > > > I have a SP that returns a int value as an alias called "returnvalue". I > > can > > call the SP fine in my code. > > conLog = New > > SqlConnection("Server=localhost;uid=*****;pwd=*****;database=footbet") > > cmdLog = New SqlCommand("loginStore", conLog) > > > > cmdLog.CommandType = CommandType.StoredProcedure > > cmdLog.Parameters.IndexOf("@InUse") > > conLog.Open() > > cmdLog.ExecuteScalar() > > myMainfrm.Show() > > > > conLog.Close() > > > > No I can look at my dataAdapter and preview my return value from my store > > procedure. So I believe the connection is just fine. I just want to be > > able > > to send that returnvalue to a text box in my program. So all I need is the > > output the SP is giving me, and put that value in a textbox. > > Can anybody point me in the right direction, and let me know what is the > > best way of doing this? > > > > As always, Thank you for your time. > > > > Rudy > > >
Other interesting topics
how to construct a Schema
filling a dataset taking toooo much time How do I "refresh" my bound control? Many data components - use one transaction? Problem with SQL Server Script... Batch queries in stored procedures? Transaction please ?? Problem to restore an SQL database.... dBase Script problem... |
|||||||||||||||||||||||