[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
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 & "))
Re: Help about save dataset to table
thanks for help GaryMazzone