How to Insert multiple rows by using array variables

dimuthu

Member
Joined
Apr 28, 2007
Messages
6
Programming Experience
Beginner
Hi friends

I have created a list of checkboxes and list of textboxes by using two control arrays. Now i want to send only selected checkbox lables and textbox values to a access 2003 database table with two data fields.

I have coded to create OleDbDataConnection and OleDbDataCommand connections.
This is my code set:

Dim cnn1 As New System.Data.OleDb.OleDbConnection
Dim cmd1 As New System.Data.OleDb.OleDbCommand
cnn1 = ConnectToNW()
cnn1.Open()
cmd1.Connection = cnn1
Dim a As Integer
Dim d As Boolean = False
Dim frm6 As New Form6

For a = 0 To 59
While (chkBox(a).Checked = True)
d = True
Exit While
End While
Next a


If d = True Then
For a = 0 To 59
If chkBox(a).Checked = True Then
cmd1.CommandText = "INSERT INTO Selected (Ingredient_Name, Price) & Values (chkbox(a).text & txtTextboxArray.text)"
cmd1.ExecuteNonQuery()
End If
Next
cnn1.Close()
Else
MsgBox("Sorry!, please select ingredients and enter their prices", MsgBoxStyle.Critical, "Invalid Selection!")
End If

This is not working. The compiler stops at the first EndIf.
How can i sole this problem?

Thanks
 
Last edited:
Your code is very broken and in a lot of places doesnt make sense.

Please read the PQ link in my signature, you arent forming your sql queries correctly at all. Actually, then also read the DW1 link in my signature, it will teacch you how to do database access properly for .NET 1.1
 
Back
Top