Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How do I insert multiple record in a loop with ado.net ?

Reply
Thread Tools

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

 
 
=?Utf-8?B?SmVmZg==?=
Guest
Posts: n/a
 
      04-14-2004
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
 
Reply With Quote
 
 
 
 
Marina
Guest
Posts: n/a
 
      04-14-2004
You should add the parameter once (outside the loop), and just change their
values inside the loop.

"Jeff" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
> 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 listItem
>
> for each zItem in Listbox1.Items
> With Cmd.Parameters
> .Add(New OleDbParameter("@IdFiche", IdCle))
> .Add(New OleDbParameter("@PathDoc", zItem.Text))
> End With
> Cmd.ExecuteNonQuery()
> next zItem



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Triple nested loop python (While loop insde of for loop inside ofwhile loop) Isaac Won Python 9 03-04-2013 10:08 AM
Insert Multiple Records Using One Insert Statemen with MySQLdb module anton.ranieri.it@gmail.com Python 1 12-06-2008 12:47 PM
How to insert a new record in detailsview when there are no record Frits van Soldt ASP .Net Web Controls 2 11-17-2005 09:18 AM
Insert multiple record into table using ado.net ? =?Utf-8?B?SmVmZg==?= ASP .Net 2 04-14-2004 01:56 AM
insert record using stored proc returns no error but doesn't inserd record ASP General 1 01-09-2004 04:53 PM



Advertisments