473,503 Members | 1,656 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reading Results From a Stored Procedure

2 New Member
OK, so I have a stored procedure that ends like this ....

Expand|Select|Wrap|Line Numbers
  1. select @PulpMill as pulp_mill, @Supplier + ' - weighted' as supplier, @Species as species
  2.  
  3. select interval_date, weight_multiplied_cqi / total_weight as average_cqi
  4. from @WeightedIntervalTable
when you actually run the procedure in the Query Analizer it works fine. However im trying to build an Interface in VB.NET that can get the results from it. So far I have....

Expand|Select|Wrap|Line Numbers
  1.         Try
  2.             myConnection.Open()
  3.             'opening the connection
  4.             myCommand = New SqlCommand( _
  5.             "exec fax_cstr_chart_data 'Hopewell', 'Pine'", myConnection)
  6.  
  7.             'executing the command and assigning it to connection 
  8.             dr = myCommand.ExecuteReader()
  9.             While dr.Read 'reading from the datareader
  10.                 'Build Row Data From DataReader
  11.                 Dim NewRow As String() = {dr.Item(0).ToString, dr.Item(1).ToString, dr.Item(2).ToString}
  12.                 Me.dgHP.Rows.Add(NewRow) 'Add New Row
  13.             End While
  14.             dr.Close()
  15.             myConnection.Close()
  16.         Catch ex As Exception
  17.             MsgBox("Error : " & ex.Message)
  18.         End Try

However it only returns the first Select statements result, then the reader closes and it doesnt return the second select statements values.... How do you setup a reader to do this???
Aug 15 '07 #1
2 1611
ilearneditonline
130 Recognized Expert New Member
You will need to use SqlDataReader.NextResult.


Link
Aug 15 '07 #2
thecodewhore
2 New Member
THANK YOU!! I knew it would be simple.
Aug 15 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
7146
by: John | last post by:
Hi everyone, I have a stored procedure which I use to query a table. The first part of the stored procedure uses a cursor to update a temp table whilst the second part of the query actually...
2
10151
by: Jegg | last post by:
I wrote a web app using an ASP front end (not .NET) connecting to a SQL Server 2000 (no SP) back end. Both the web server and the database server are Windows 2003 boxes. The app was running fine...
1
2558
by: Mihaly | last post by:
I have a stored procedure in SQL Server 2000, and I want to read the error messages from this stored procedure. Please help me for this question: This is the stored procedure. Please supose than...
4
2977
by: Mike Dinnis | last post by:
Hi, I've been working through a number of turorials to try to learn more about retrieving data from a SQL database. I think i've mastered techniques where i create a sql string in the page and...
3
2041
by: Hewit | last post by:
I have a stored procedure which returns records and output parameters(SQL2K). How to call this stored procedure using ADO.Net so that I can use both results in my application. I have .Net...
2
2008
by: Sandy | last post by:
Hello - I have the following stored procedure and code. I want to put the results in two textboxes. I get to the part where I create the dataset and then I don't know what to do. I tried...
6
2698
by: Jim | last post by:
Can someone, please, show me how to display the results of a stored procedure in a VB.NET datagrid on a winform? I'm a newbie. Here's my SQL 2000 stored precedure that returns the status of...
1
2292
by: Chris | last post by:
Hi, I created a VB SQL CRL Stored procedure for calculating a value. Value is returned as below Using sConn4 As New SqlConnection("context connection=true") sConn4.Open() scmd = New...
4
7839
by: Utahduck | last post by:
I do a lot of file processing and I usually run a little script I copy and paste to read directory information to see if a new file it there and then process the file if it is. So, I decided to...
0
7202
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7084
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7278
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7458
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1512
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.