How do I insert multiple record in a loop with ado.net ?

G

Guest

I have to insert all Items of a listbox to a table ? How can I do that ? The code bellow always add the same first item to the table. must be another way to do this. Thank'

Dim Conn As String = "Provider=Microsoft.Jet.OLEDB......
Dim strSQL = "Insert into Documents (IdFiche, PathDoc) values (@IdFiche, @PathDoc);
Dim Cmd As New OleDbCommand(strSQL, Conn
dim zItem as listIte

for each zItem in Listbox1.Item
With Cmd.Parameter
.Add(New OleDbParameter("@IdFiche", IdCle)
.Add(New OleDbParameter("@PathDoc", zItem.Text)
End Wit
Cmd.ExecuteNonQuery(
next zItem
 
M

Marina

You should add the parameter once (outside the loop), and just change their
values inside the loop.

Jeff said:
I have to insert all Items of a listbox to a table ? How can I do that ?
The code bellow always add the same first item to the table. must be another
way to do this. Thank's
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top