|
-
Feb 6th, 2006, 10:07 AM
#1
Thread Starter
Fanatic Member
Adding more than 1 row to dataset
Hi Guys
Added 1 rec to Access 2000 db from vb.net (1.1), now want to add more than 1... have I done this right?
Unsure of syntax/ order
cheers George
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & myDBLoc)
Dim cmd = New OleDbCommandBuilder(da)
da = New OleDbDataAdapter("Select * from tblDocs", cn)
da.Fill(dt)
cmd = New OleDbCommandBuilder(da)
Try
da.Fill(ds, "Scans")
dt = ds.Tables("Scans")
Dim dr As DataRow = dt.NewRow()
Dim di As New System.IO.DirectoryInfo(myFileNetDrive)
For Each fi As System.IO.FileInfo In di.GetFiles("*.*")
'lstFiles.Items.Add(fi.Name)
dr(1) = myKeyNo.Text
dr(2) = fi.Name
dr(3) = "9"
dr(4) = Date.Now
dt.Rows.Add(dr)
Next
da.Update(ds, "Scans")
Last edited by Ggalla1779; Feb 6th, 2006 at 11:32 AM.
-
Feb 6th, 2006, 10:10 AM
#2
Hyperactive Member
Re: Adding more than 1 row to dataset
Without looking at your code in detail the basics seem to be there. I would suggest you try rnning it and see if you get any errors!
Is there a specific point on which you are unsure?
-
Feb 6th, 2006, 10:11 AM
#3
Thread Starter
Fanatic Member
Re: Adding more than 1 row to dataset
first row is added then, then at 2nd dt.Rows.Add(dr) it cracks up
-
Feb 6th, 2006, 10:15 AM
#4
Hyperactive Member
Re: Adding more than 1 row to dataset
oh ic.
inside your for loop you need to create a new instance of your datarow. What your code does currently is try to add teh same datarow (with potentially different values) twice.
Thus inside your for loop add the line
dr = dt.newrow
-
Feb 6th, 2006, 11:31 AM
#5
Thread Starter
Fanatic Member
Re: Adding more than 1 row to dataset
Thanks Duck that worked a treat...now have multiple new records in my wee database
cheers George
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|