?
Solved

Saving changes to an access table

Posted on 2007-10-12
10
Medium Priority
?
170 Views
Last Modified: 2010-04-23
I am trying to save changes made to a form using the following code.

Me.Validate()
        Me.MessageBindingSource.EndEdit()
        Me.MessageTableAdapter.Update(Me._CAD_050107DataSet.message)

The access database has a primary key so I know that is not the problem. However in my dataset designer I added something to the sql for the table to show only results where a checkbox is false. Not sure if this is causing the problem. Here is the SQL.

SELECT AutoNumber, [Check], [Date], [Time], BOLO FROM message where [check] = false
0
Comment
Question by:wiswalld
  • 5
  • 5
10 Comments
 
LVL 18

Expert Comment

by:Priest04
ID: 20066168
You should check the CommandText for the UpdateComand, DeleteCommand and InsertCommand to see if they contain valid SQL statements

Goran

0
 
LVL 13

Author Comment

by:wiswalld
ID: 20067815
Not sure what you mean but here is the error:

Update requires a valid UpdateCommand when passed DataRow collection with modified rows.
0
 
LVL 18

Expert Comment

by:Priest04
ID: 20068079
In the dataset designer, select MessageTableAdapter, and look at its properties window (F4). There you can see command objects, and their CommandText property. Check this property to see if it is a valid query.

Goran
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 13

Author Comment

by:wiswalld
ID: 20068110
Says none update update command
0
 
LVL 18

Expert Comment

by:Priest04
ID: 20068169
That means that you didn't generate Update, Insert and Delete command objects, that you have only created readonly dataset. You need to regenerate dataset adain in designer. You need to check in it Insert. Update, and Delete options. After you generate it, when you press on a [+] sign left from it, it will display its properties, and you will see CommandText property that will hold something like

UPDATE TableName...........................

Goran
0
 
LVL 13

Author Comment

by:wiswalld
ID: 20069254
OK at that point but noy sure how to proceed. I selected the field that will need to be updated after adding the table but unsure from here.
0
 
LVL 18

Expert Comment

by:Priest04
ID: 20069331
You need to right click on a table that is in dataset designer, choose Configure, then click on the Advanced options (something like that, I am typing from head), then check option to generate insert, update and delete statements.

Goran
0
 
LVL 13

Author Comment

by:wiswalld
ID: 20071986
>>>>>>That means that you didn't generate Update, Insert and Delete command objects, that you have only created readonly dataset. You need to regenerate dataset adain in designer. You need to check in it Insert. Update, and Delete options. After you generate it, when you press on a [+] sign left from it, it will display its properties, and you will see CommandText property that will hold something like

UPDATE TableName...........................

So I did what you suggested and selected new for the update command and was brought to a query builder. Asked to select a table and I selected the table I wanted and the field I will need to update. This is what I have so far below. Not sure what to do.




UPDATE    message
SET              [Check] =
0
 
LVL 18

Accepted Solution

by:
Priest04 earned 1000 total points
ID: 20072487
You didn't take into reconsideration my last post, wizard will generate them for you, you just need to check option

[Quote]

You need to right click on a table that is in dataset designer, choose Configure, then click on the Advanced options (something like that, I am typing from head), then check option to generate insert, update and delete statements.

{/quote]

Goran
0
 
LVL 13

Author Comment

by:wiswalld
ID: 20155880
You were correct. I thought I had created a primary key in my access table but had only created an autonumber field and not designated it as a primary key.



STUPID!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
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…
Suggested Courses
Course of the Month15 days, 9 hours left to enroll

850 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