sql insert query for inserting mutliple records
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
A name1 1
A name2 1
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
Re: sql insert query for inserting mutliple records
Try
Code:
Dim i As Integer
For i = 0 To ListBox1.Items.Count - 1
If ListBox1.GetSelected(i) = True Then
'execute insert query here
End If
Next
Re: sql insert query for inserting mutliple records
Quote:
Originally Posted by Hack
Try
Code:
Dim i As Integer
For i = 0 To ListBox1.Items.Count - 1
If ListBox1.GetSelected(i) = True Then
'execute insert query here
End If
Next
hi
i tried the same but after the if listbox1................. statement the program comes to end if , it doesnt go thr' the execute statement