BetsyV
asked on
ASP.NET data reader for next loop
I'm very new to .NET, and playing with syntax that I just can't get right.
I have a sql command that reads a number of records from my database. In the table, there is a field called APPROVED. When the user clicks a button, it reads the data. If the field APPROVED has the value of HOLD, I want to exit the subroutine. I was trying to put the value into a label, so I could test this out, and I can get it to read the last record fine. I know I need a For / Next loop in the middle of this, but my brain must have gone because I can't get it right. I've taken out all the things I tried, so you wouldn't wonder -- why that.
Here is the basic structure of the code:
'select statement is above here
dtrFinal = SqlSelectCostCenters.Execu teReader()
While dtrFinal.Read
Label1.Text = (dtrFinal("Approved"))
If Label1.Text = "HOLD" Then
dtrFinal.Close()
SqlConnection1.Close()
Exit Sub
Else
'Label1.Text = "YOU ARE GOOD TO GO"
End If
End While
SqlConnection1.Close()
How can I get it to exit the sub if it comes across a record with the word "HOLD" in the field called approved??
THANK YOU as always for any suggestions.
I have a sql command that reads a number of records from my database. In the table, there is a field called APPROVED. When the user clicks a button, it reads the data. If the field APPROVED has the value of HOLD, I want to exit the subroutine. I was trying to put the value into a label, so I could test this out, and I can get it to read the last record fine. I know I need a For / Next loop in the middle of this, but my brain must have gone because I can't get it right. I've taken out all the things I tried, so you wouldn't wonder -- why that.
Here is the basic structure of the code:
'select statement is above here
dtrFinal = SqlSelectCostCenters.Execu
While dtrFinal.Read
Label1.Text = (dtrFinal("Approved"))
If Label1.Text = "HOLD" Then
dtrFinal.Close()
SqlConnection1.Close()
Exit Sub
Else
'Label1.Text = "YOU ARE GOOD TO GO"
End If
End While
SqlConnection1.Close()
How can I get it to exit the sub if it comes across a record with the word "HOLD" in the field called approved??
THANK YOU as always for any suggestions.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Glad to help, BetsyV .
Regards
x_com
Regards
x_com
ASKER
THANKS !