473,387 Members | 3,787 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

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
Nov 18 '05 #1
1 2416
You should add the parameter once (outside the loop), and just change their
values inside the loop.

"Jeff" <an*******@discussions.microsoft.com> wrote in message
news:A1**********************************@microsof t.com...
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

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: jason | last post by:
How does one loop through the contents of a form complicated by dynamic construction of checkboxes which are assigned a 'model' and 'listingID' to the NAME field on the fly in this syntax:...
10
by: shank | last post by:
I have a recordset that contains multiple records of product a user is purchasing. For clarity, I converted the recordset fields to variables. I need to take that entire recordset and insert it...
8
by: Sans Spam | last post by:
Greetings! I have a table that contains all of the function permissions within a given application. These functions are different sections of a site and each has its own permissions (READ, WRITE,...
3
by: ben.werdmuller | last post by:
Hi, Is there an easy way in ASP/VBscript to grab an autonumber (primary key) field just after an SQL insert? This is probably easy, but I'm stuck .. Cheers.
10
by: Mike | last post by:
I know this sounds strange but I am at a loss. I am calling a simple funtion that opens a connection to a SQL Server 2000 database and executes an Insert Statement. private void...
4
by: Mike Hnatt | last post by:
My goal is to get data from an XML file into a couple of tables in an Access database. The XML file is a little complex so I need control over what I do (I can't just read it into a dataset). ...
2
by: Jeff | last post by:
I need to insert into a table multiple item of a listbox. (item.text and item.value Right now, I'm using an OleDBConnection with Access, a Command(Insert string) and parameters. I don't see how an...
8
by: SaltyBoat | last post by:
Needing to import and parse data from a large PDF file into an Access 2002 table: I start by converted the PDF file to a html file. Then I read this html text file, line by line, into a table...
0
chumlyumly
by: chumlyumly | last post by:
Hello scripters - OS: Mac OSX Language: PHP w/ MySQL database I've created an insert page where a user inputs his info, which then goes to four different tables in a MySQL database. The...
3
by: uma9 | last post by:
hi, the code below is used to insert a single record....i want to know how to insert multiple records using a "for" loop...please help Set connect = CreateObject ("ADODB.Connection")...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.