|
-
Apr 14th, 2010, 10:01 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] Help about save dataset to table
i want to save dataset from table (bible) to another table (tt) in access 2003 database
this is the code i have
vb Code:
Private Sub Option1ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Option1ToolStripMenuItem.Click
Dim sQuery As String = "SELECT Bible.BookNum, Bible.ChapterNum, Bible.VerseNum FROM BibleBookNames INNER JOIN Bible ON BibleBookNames.BookNum = Bible.BookNum WHERE (((BibleBookNames.Book)=""" & DataGridView1.Rows(DataGridView1.CurrentRow.Index).Cells(0).Value.ToString & """) AND ((Bible.ChapterNum)= " & ComboBox2.Text & ") AND ((Bible.VerseNum)=" & DataGridView1.Rows(DataGridView1.CurrentRow.Index).Cells(1).Value.ToString & "));"
Dim SQLQuery As New OleDbDataAdapter(sQuery, CON)
Dim dsResult As New DataSet
SQLQuery.Fill(dsResult, "tt")
Dim sCollection As String = "Select * from tt;"
Dim daCollection As New OleDbDataAdapter(sCollection, CON)
Dim objCommandBuilder As New OleDbCommandBuilder(daCollection)
daCollection.Update(dsResult, "tt")
End Sub
but nothing happen or being saved to the other table which is tt
-
Apr 14th, 2010, 10:14 AM
#2
Re: Help about save dataset to table
No need to do that... Why take the overhead of moving the data from the database to the client and back to the database....
This can all be done in 1 SQL statement and happen directly on the database
Insert into TableName (FieldName1,FieldName2,....) Select Field1,Field2,.... From table
Code:
INSERT INTO whaterTableName (BookNummChapterNum,VerseNum)
SELECT Bible.BookNum, Bible.ChapterNum, Bible.VerseNum FROM BibleBookNames INNER JOIN Bible ON BibleBookNames.BookNum = Bible.BookNum WHERE (((BibleBookNames.Book)=""" & DataGridView1.Rows(DataGridView1.CurrentRow.Index).Cells(0).Value.ToString & """) AND ((Bible.ChapterNum)= " & ComboBox2.Text & ") AND ((Bible.VerseNum)=" & DataGridView1.Rows(DataGridView1.CurrentRow.Index).Cells(1).Value.ToString & "))
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Apr 14th, 2010, 02:10 PM
#3
Thread Starter
Fanatic Member
Re: Help about save dataset to table
thanks for help GaryMazzone
Last edited by new1; Apr 14th, 2010 at 02:15 PM.
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
|