By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,168 Members | 2,511 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,168 IT Pros & Developers. It's quick & easy.

OledbDataAdapter update

P: n/a
I have wrote function that upgrades access database

Public Function UpdateDataTable(ByRef po_dt As System.Data.DataTable) As Boolea
Dim conn As New OleDbConnection(mstrConnectionString
Dim sTblName As String = po_dt.TableNam
Dim dt As Data.DataTabl
Dim da As New OleDbDataAdapter("SELECT * FROM " & sTblName, conn
Dim custCB As OleDbCommandBuilder = New OleDbCommandBuilder(da
Tr
dt = po_d
da.Update(dt.Select(Nothing, Nothing, DataViewRowState.Deleted)
da.Update(dt.Select(Nothing, Nothing, DataViewRowState.ModifiedCurrent)
da.Update(dt.Select(Nothing, Nothing, DataViewRowState.Added)
UpdateDataTable = Tru
Catch ex As Exceptio
UpdateDataTable = Fals
Throw e
End Tr
End Functio

That function returns me true (update success) but I can not see it in the data base. Someone knows what can be a problem?
Nov 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Cor
Hi Skiff,

The dataadapter updates from a dataset.

And therefore I find it strange that it returns a true.

Have a look at this for a class description

http://msdn.microsoft.com/library/de...classtopic.asp

Something what I think what will go wrong if you have readed it and start
changing..

"The dataset needs to have a schema and constraints from the table(s) in the
database".

I hope this helps?

Cor

I have wrote function that upgrades access database:

Public Function UpdateDataTable(ByRef po_dt As System.Data.DataTable) As Boolean Dim conn As New OleDbConnection(mstrConnectionString)
Dim sTblName As String = po_dt.TableName
Dim dt As Data.DataTable
Dim da As New OleDbDataAdapter("SELECT * FROM " & sTblName, conn)
Dim custCB As OleDbCommandBuilder = New OleDbCommandBuilder(da)
Try
dt = po_dt
da.Update(dt.Select(Nothing, Nothing, DataViewRowState.Deleted)) da.Update(dt.Select(Nothing, Nothing, DataViewRowState.ModifiedCurrent)) da.Update(dt.Select(Nothing, Nothing, DataViewRowState.Added))
UpdateDataTable = True
Catch ex As Exception
UpdateDataTable = False
Throw ex
End Try
End Function

Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.