|
-
May 16th, 2013, 07:03 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] dataset, datatable, add records/tables at the end
Hi
im having a stupid problem and i dont know why
what i want is just to put a list of datatables into 1 table
Code:
Dim MyConnection As System.Data.OleDb.OleDbConnection
Dim DtSet As System.Data.DataTable
Dim MyCommand As System.Data.OleDb.OleDbDataAdapter
MyConnection = New System.Data.OleDb.OleDbConnection(ConnectionString)
MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * from [test$]", MyConnection)
MyCommand.TableMappings.Add("Table", "TestTable")
DtSet = New System.Data.DataTable
MyCommand.Fill(DtSet)
testtables.Add(DtSet)
MyConnection.Close()
MyConnection = New System.Data.OleDb.OleDbConnection(ConnectionString)
MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * from [test$]", MyConnection)
MyCommand.TableMappings.Add("Table", "TestTable")
DtSet = New System.Data.DataTable
MyCommand.Fill(DtSet)
testtables.Add(DtSet)
MyConnection.Close()
DtSet = New System.Data.DataTable("Test")
For Each item As System.Data.DataTable In testtables
For Each item2 As DataRow In item.Rows
DtSet.ImportRow(item2)
Next
Next
DataGridView1.DataSource = DtSet
sometimes i get an error saying the column f1 is already used by the othertable - if so how do i get around that
sometimes i get no error but an empty gridview
could i not just insert the tables straight into a dttable when i get the data from the connection?
please help
Yes!!!
Working from home is so much better than working in an office...
Nothing can beat the combined stress of getting your work done on time whilst
1. one toddler keeps pressing your AVR's power button
2. one baby keeps crying for milk
3. one child keeps running in and out of the house screaming and shouting
4. one wife keeps nagging you to stop playing on the pc and do some real work.. house chores
5. working at 1 O'clock in the morning because nobody is awake at that time
6. being grossly underpaid for all your hard work

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
|