Re: ADO.NET cmd.ExecuteReader OUTPUT parameters
Russell Collins <[email protected]> Thu, 14 Jun 2007 09:02:01 -0500
| Newsgroups | gmane.comp.windows.devel.dotnet.cx |
|---|---|
| Message-ID | <[email protected]> |
I see. The only other way that I can think of doing this is by populating a dataset and using the methods in the dataset to get the count. With that solution you wouldn't need a rowcount output parameter and you would only need the three recordsets that contain the data that you need back. Then, you would do something like this to get the row count for the recordset: int s1 =3D objDS.Tables[0].Rows.Count; //Rowcount for first recordset =20 int s2 =3D objDS.Tables[1].Rows.Count; //Rowcount for second recordset int s3 =3D objDS.Tables[2].Rows.Count; //Rowcount for third recordset Russell -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Peter Osucha Sent: Thursday, June 14, 2007 8:55 AM To: Discussion relating to the specifics of the C# and Managed C++ languages Subject: RE: [DOTNET-CX] ADO.NET cmd.ExecuteReader OUTPUT parameters That is actually what I've done, Russell. It just seemed that there would be a better solution. =20 My issue with doing that (and perhaps it isn't a big issue at all) is that I was getting the @@RowCount after calling the select statement - and assigning the output parameter from @@RowCount. If returning a recordset with the RowCount before returning the actual records from the select statement, then you can't use @@RowCount but need to use a SELECT COUNT(someparam) statement instead. It just seemed that there must be a better way. This seems to be a somewhat common need and has been since at least the beginning of ADO. I wonder why they (MS - or whomever develops the ADO code) doesn't provide this update before closing the datareader? Peter -----Original Message----- From: Discussion relating to the specifics of the C# and Managed C++ languages [mailto:[email protected]] On Behalf Of Russell Collins Sent: Thursday, June 14, 2007 9:30 AM To: [email protected] Subject: Re: [DOTNET-CX] ADO.NET cmd.ExecuteReader OUTPUT parameters From what I understand, you won't be able to access the Output parameter until you are done with the DataReader. One solution could be to turn the output parameter into another recordset and make it the 2nd one to be retrieved. Example: Select somevalue from firsttable Select 'OutputValue' Select somevalue from secondtable Select somevalue from thirdtable -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Peter Osucha Sent: Thursday, June 14, 2007 8:27 AM To: Discussion relating to the specifics of the C# and Managed C++ languages Subject: ADO.NET cmd.ExecuteReader OUTPUT parameters It's been a while since I did this in VB6 - I can't seem to recall the best way to go about it. I have a SQLDataReader object being returned from an ExecuteReader() method on a SqlCommand object that is calling a stored procedure.=20 =20 The returned SQLDataReader contains 3 'Results' (it is returning 3 separate recordsets) and the stored procedure being called also updates an OUTPUT parameter. I need to know the OUTPUT parameter value before processing the third of the 'Results'. However, I can't get the updated OUTPUT parameter until I close the DataReader - after which I cannot go back and loop through the 3rd of the 'Results'. =20 What is a solution to this problem, please ('m reluctantly hoping it isn't to return a single value in a 'Result' between the current 2nd and 3rd results with a recordset having one value- that of the OUTPUT parameter I want)? =20 Peter =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D This list is hosted by DevelopMentor(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D This list is hosted by DevelopMentor=AE http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com