P
pvong
I'm trying to do this in VB.NET
I have 10 TextBoxes in a Panel. All I want to do is loop through each box
and see if it's empty. If it's not empty, do the Insert. The first Insert
works but it fails at the next TextBox because it needs a unquie variable.
Can someone help me figure out a way so the variable will be unique through
each loop?
For Each ctrl As Control In Panel3.Controls
If TypeOf ctrl Is TextBox Then
If Not CType(ctrl, TextBox).Text = String.Empty Then
ds.InsertCommand = "INSERT INTO LpCC2 (CcID, LpClientsID) VALUES
(@CcID4,@LpClientsID4)"
ds.InsertParameters.Add("CcID4", "10")
ds.InsertParameters.Add("LpClientsID4", CType(ctrl, TextBox).Text)
ds.Insert()
End If
End If
Next
The variable name '@CcID4' has already been declared. Variable names must be
unique within a query batch or stored procedure.
Thanks!
I have 10 TextBoxes in a Panel. All I want to do is loop through each box
and see if it's empty. If it's not empty, do the Insert. The first Insert
works but it fails at the next TextBox because it needs a unquie variable.
Can someone help me figure out a way so the variable will be unique through
each loop?
For Each ctrl As Control In Panel3.Controls
If TypeOf ctrl Is TextBox Then
If Not CType(ctrl, TextBox).Text = String.Empty Then
ds.InsertCommand = "INSERT INTO LpCC2 (CcID, LpClientsID) VALUES
(@CcID4,@LpClientsID4)"
ds.InsertParameters.Add("CcID4", "10")
ds.InsertParameters.Add("LpClientsID4", CType(ctrl, TextBox).Text)
ds.Insert()
End If
End If
Next
The variable name '@CcID4' has already been declared. Variable names must be
unique within a query batch or stored procedure.
Thanks!