|
-
Aug 17th, 2007, 10:55 AM
#1
Thread Starter
Hyperactive Member
Results from Stored Procedure to textboxes
I have a stored procedure that returns results like this:
Store#, Qty, and Item (see example below).
1, 3, Fountain Drinks
1, 2, CandyBars
1, 5, Hard Candies
I am trying to take those results and put them into text boxes on my form but so far all I have been able to do is get the last record to show on my form. What I need to do is to put the QTY of Fountain Drinks in the tbStoreFF textbox and ten QTY of CandyBars in the tbStoreCB textbox. How can I accomplish that? The code below is what I have managed thus far.
vb Code:
Private Sub ExecuteCountServices(ByVal parStore As String, _
ByVal parStart As DateTime, ByVal parEnd As DateTime)
Dim strSp As String = "sp_CountServicesStore"
Dim cn As SqlConnection = New SqlConnection
Dim cmd As SqlCommand = New SqlCommand(strSp, cn)
Dim dr As SqlDataReader
cn.ConnectionString = Con
cn.Open()
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add("@Store", SqlDbType.VarChar).Value = parStore
cmd.Parameters.Add("@StartDate", SqlDbType.DateTime).Value = parStart
cmd.Parameters.Add("@EndDate", SqlDbType.DateTime).Value = parEnd
tbMyStore.Text = parStore
tbMyStart.Text = CStr(parStart)
tbMyEnd.Text = CStr(parEnd)
Try
dr = cmd.ExecuteReader()
While dr.Read()
With dr
tbStoreFF.Text = CStr(.Item("QTY"))
' textbox for Fountain Drinks here
' textbox for candy bars
' textbox for hard candies
End With
End While
Catch ex As Exception
MessageBox.Show(ex.Message & vbNewLine & _
ex.Source, "Data Error", MessageBoxButtons.OK)
End Try
End Sub
Last edited by FastEddie; Aug 17th, 2007 at 12:31 PM.
-
Aug 17th, 2007, 12:19 PM
#2
Re: Results from Stored Procedure to textboxes
Moved to database development
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|