Re: SQL Server dataset to ACCESS dataset
I need to grab data from table tblClub of a SQL Server db and copy it to table tblClub of an ACCESS db.
I have the following piece of code which calls an onclick event to
grab data into dataset of the Server db then delete all in LOCAL before filling the LOCAL dataset with the SERVER dataset.
I then use the .update property which should update the LOCAL database.
My problem is that it is not updating the LOCAL database. Can anyone help?
Dazzer
The code......
Private Sub btnDownloadAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDownloadAll.Click
'Lets assign for Server table and row objects
Dim objTableSQL As DataTable
Dim objRowSQL As DataRow
'Lets assign for Local table and row objects
Dim objTableLOCAL As DataTable
Dim objRowLOCAL As DataRow
Dim objDR As Data.DataRow
'Local Variables
Dim theRow As Integer
Dim theCol As String
Dim intCounter As Integer
Dim intColCounter As Integer
'Error Handler - to catch a broken db Connection Path
Try
objLocalConn.Open()
'This code will delete all from local table for a fresh insert
Dim strSQL As String = "DELETE * FROM tblClub"
Dim cmd As New System.Data.OleDb.OleDbCommand(strSQL, objLocalConn)
cmd.ExecuteNonQuery()
Catch obj2 As Exception
MessageBox.Show(obj2.ToString())
Finally
objServerConn.Close()
End Try
'Grab from the DataSet
objTableSQL = objDSServer.Tables("tblClub")
objTableLOCAL = objDSLocal.Tables("tblClub")
'Clear and Fill the Data Adapter
'objDSLocal.Clear()
objDALocal.Fill(objDSServer)
objDAServer.Fill(objDSLocal)
Try
objDALocal.Update(objDSLocal, "tblClub")
Catch q As Exception
MessageBox.Show(q.ToString())
End Try
'objDAServer.Update(objDSLocal, "tblClub")
objLocalConn.Close()
objServerConn.Close()
'Update the Datasource with the DataSet
'Update the database
'objDSLocal.Clear()
'objDALocal.Fill(objDSLocal)
'Next
MessageBox.Show("Download from Server is Complete")
End Sub
|