Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / ADO.NET / June 2004

Tip: Looking for answers? Try searching our database.

BUG? SELECT statment w/ Return Value doesn't work together

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jordan - 29 Jun 2004 22:13 GMT
What I'm trying to do is exectue a stored procedure that returns some
records along with an additional RETURN value. The code is below:

***
SqlConnection Conn = new SqlConnection
(System.Configuration.ConfigurationSettings.AppSettings["MyConn"]);
SqlCommand Cmd = new SqlCommand("spMySP", Conn);
Cmd.CommandType = CommandType.StoredProcedure; Cmd.Parameters.Add (new
SqlParameter("@RowCount", SqlDbType.Int));
Cmd.Parameters["@RowCount"].Direction = ParameterDirection.ReturnValue;
Cmd.Parameters.Add (new SqlParameter("@Parm1", SqlDbType.VarChar, 5));
Cmd.Parameters["@Parm1"].Value = Parm1;
Conn.Open(); SqlDataReader DR = Cmd.ExecuteReader();
Message.Text = Cmd.Parameters["@RowCount"].Value.ToString();  !!!!
***

The problem (i.e. bug) is that I can do either get the results, or get the
return value, but not both. When I have the SELECT statement in the Stored
Proc, it runs and I can bind the DataReader results to a Repeater, but when
then I get a compile error on the line marked above with "!!!!." If I
comment out the line, it works. On the otherhand, if I comment out the
SELECT statement in my Stored Proc, everything compiles and I can see my
return value in the <asp:label id="Message"> field. WHAT THE ...?

Any ideas?

j
William Ryan  eMVP - 29 Jun 2004 22:48 GMT
Try calling While dr.Read --- check out Retrieving the Gozoutas by Bill
Vaugh at www.betav.com -> Articles -> MSDN

Signature

W.G. Ryan MVP Windows - Embedded

http://forums.devbuzz.com
http://www.knowdotnet.com/dataaccess.html
http://www.msmvps.com/williamryan/

> What I'm trying to do is exectue a stored procedure that returns some
> records along with an additional RETURN value. The code is below:
[quoted text clipped - 23 lines]
>
> j
Jordan - 29 Jun 2004 23:14 GMT
How will that work with the method I'm currently working on. I'd like to use
WebControls where possible and not a custom loop if I don't have to.

Jordan

> Try calling While dr.Read --- check out Retrieving the Gozoutas by Bill
> Vaugh at www.betav.com -> Articles -> MSDN
[quoted text clipped - 27 lines]
> >
> > j
Jordan - 29 Jun 2004 23:20 GMT
Oops...didn't close the DataReader, that was the problem. Thanks for the
article, great stuff.

Jordan

> Try calling While dr.Read --- check out Retrieving the Gozoutas by Bill
> Vaugh at www.betav.com -> Articles -> MSDN
[quoted text clipped - 27 lines]
> >
> > j
William \(Bill\) Vaughn - 30 Jun 2004 18:46 GMT
"Vaughn"... ;)

Signature

____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

> Try calling While dr.Read --- check out Retrieving the Gozoutas by Bill
> Vaugh at www.betav.com -> Articles -> MSDN
[quoted text clipped - 27 lines]
> >
> > j
William Ryan eMVP - 30 Jun 2004 19:17 GMT
Sorry about that - I type it enough I ought to know it by now ;-)

Signature

W.G. Ryan, eMVP

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/community/newsgroups

> "Vaughn"... ;)
>
[quoted text clipped - 31 lines]
> > >
> > > j

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.