insert query fr multiple listbox records

svibuk

Active member
Joined
Jul 15, 2008
Messages
31
Programming Experience
1-3
i have a listbox with more than one record, 2 textbox
i want to insert the data from all 3 objects in the sql table but with the below code i am not able to insert it.

eg suppose i have 2 names in listbox1 , name1, name 2 & in first textbox A & second textbox "1"
against both the names the data of text box shld be insetred
eg
VB.NET:
   A    name1  1
   A    name2  1


VB.NET:
For i = 1 To ListBox1.Items.Count

                If ListBox1.Items(i - 1).selected = True Then

                   strqry = "insert into trans(cid,pid,lid) values('" & textBox1.Text & "','" & ListBox1.Items(i - 1) & "','" & textBox2.Text & "')"
                    cmd.CommandText = strqry
                      cmd.ExecuteNonQuery()
end if
next
 
I'm kind of new to parameterized queries but I didn't think you needed quotation marks around the values.
 
svibuk, please read the DW2 link in my signature to find out how you should be doing your data access
 

Latest posts

Back
Top