Private Sub FCountTotalOrderID() '--- retrieve OrderID Row count from Table --- Dim strsql As String strsql = " Select count(OrderID) as [intTotalOrderID]" strsql &= " From TblOrders " strsql &= " Where (CustomerID = N'" & strCustID & "')"
sqlconn = New SqlConnection(connstr) sqlcmd = New SqlCommand(strsql, sqlconn) sqlcmd.Connection.Open()
DR = sqlcmd.ExecuteReader
If DR.HasRows = True Then While DR.Read() intTotalOrderID = DR.GetValue(0) Me.txtTotalOrderID.Text = DR.GetValue(0).ToString End While End If
sqlconn.Close() DR.Dispose() End Sub
'--- Using FOR LOOP TO FILL TEXTBOX ON FORM AND DISPLAY PROGRESSBAR ---
Private Sub BtnForLoopAction_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnForLoopAction.Click
Dim intI As Integer = 0 Dim intX As Integer = 0 Dim strOrdID As String Dim strRowNum As String Dim strsql As String
strsql = "Select OrderID from TblOrders " strsql &= " Where (CustomerID = N'" & strCustID & "')" strsql &= " Order by OrderID "
sqlconn = New SqlConnection(connstr) sqlconn.Open() DA = New SqlDataAdapter(strsql, sqlconn) DS = New System.Data.DataSet DA.Fill(DS, "Order")
Me.ProgressBar1.Maximum = intTotalOrderID Me.ProgressBar1.Minimum = 0 Me.ProgressBar1.Value = 0 For intI = 1 To intTotalOrderID Step 1
'--- Display Progress Bar --- If Me.ProgressBar1.Maximum <> intI Then Me.ProgressBar1.Value = intI End If
'--- Fill Form TextBox --- Me.TextOrderID.Text = DS.Tables("Order").Rows(intI)("OrderID").ToString Me.TextRow.Text = intI.ToString
Next intI
End Sub
THANK YOU VERY MUCH FOR HELPING MECHEERS,LENNIE