Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Error when I updating...

Posted on 2006-10-25
4
Medium Priority
?
208 Views
Last Modified: 2010-04-23
When I edit a column in the datagridview and hit save... i receive the following error...

"Update requires a valid UpdateCommand when passed DataRow collection with modified rows."

here is the code ...

Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click

        Me.Validate()
        Me.TblTransactionBindingSource.EndEdit()
        Me.TblTransactionTableAdapter.Update(Me.DsRoomReservation.tblTransaction) '<--error is here

End Sub

DatagridView was binded to BindingSourceNavigator... Any ideas?

{Jack}
0
Comment
Question by:JackOfPH
  • 2
  • 2
4 Comments
 
LVL 9

Expert Comment

by:DjDezmond
ID: 17801495
It looks like you done have a usable update command for your adapter, this is the same kind of problem to one i had in Q http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/VB_DOT_NET/Q_22023152.html

It describes creating a OLEDbCommandBuilder to create the commands for you.

It may be the same fix for you...?

Let me know how you get on...
0
 
LVL 15

Author Comment

by:JackOfPH
ID: 17801516
I am a new in vb.net I am using vb 2005 express edition...

How can I create OLEDbCommandBuilder when I use Table adapter?
0
 
LVL 15

Author Comment

by:JackOfPH
ID: 17801532
Hi, DJDezmond,

I agree, we have the same problem... but where should I place the OLEDBCommandBuilder? I use TABLEADAPTER?

Waiting for your post ...
Thanks...

{Jack}
0
 
LVL 9

Accepted Solution

by:
DjDezmond earned 2000 total points
ID: 17801577
Just before you fill your table(s) from the adapater...

In my code...

   Sub InitializeStores()
        DBAdapter = New Data.OleDb.OleDbDataAdapter("SELECT * FROM tblTunes", DBConn)
        Dim cb As OleDbCommandBuilder = New OleDbCommandBuilder(DBAdapter )                '<------------------
        DBAdapter.Fill(DataStore)
    End Sub

Replace DBAdapter for TABLEADAPTER.

You may have to post your code if you still struggle so I can see how your initializing the adapter (at the moment I am assuming that your 'tableadapter' is in fact declared as a DBAdapter)

Dez
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Integration Management Part 2
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question