Add records on button click

Nov 8 2009 11:56 PM

Hello Everybody.
I am doing a windows appln in vb.net.
I have a button in my form. When i click the button, textboxes are added dynamically to the form. For 1st click 4 textboxes are added. When clicked again, again the textboxes are added once again...Now i need to save the data from the textboxes to database. Pls anyone help me with that. Here is my coding.

Dim value1 As String = ""
Dim value2 As String = ""
Dim value3 As String = ""
Dim value4 As String = ""
Dim i As Integer
For i = 0 To FlowLayoutPanel1.Controls.Count - 1
Select Case FlowLayoutPanel1.Controls(i).Name

Case "TextBox1"
value1 = FlowLayoutPanel1.Controls(i).Text

Case "TextBox2"
value2 = FlowLayoutPanel1.Controls(i).Text

Case "TextBox3"
value3 = FlowLayoutPanel1.Controls(i).Text

Case "TextBox4"
value4 = FlowLayoutPanel1.Controls(i).Text
End Select
Next i
Dim strsql As String
strsql = "insert into stud values ('" & value1 & "','" & value2 & "','" & value3 & "','" & value4 & "')"

Only the text in the first four textboxes is getting aded to the database.What about the others

Thanks in advance

Answers (1)