Solved

Cannot Update a change to DB Table

Posted on 2004-09-15
8
312 Views
Last Modified: 2010-05-18
Hi,

Thanks for clicking

I have GridEx (like a DataGrid) that's ource Table is Tbl_Alarms in an Access 2000 DB.

It bound to it through a DataAdapter and DataSet. This DataAdapter is a join between two tables Tbl_Alarms and Tbl_LocalTempAlarmsListBox.

I am simply looking to update two columns which are the only columns that can be changed (columns named ForeColor and BackColor)

Whenever I change the colour of the GridEx Row, I change the value of the columns ForeColor and BackColor to the rgb number associated.

Then after this change I send the info back to the DB table so that the changes are recorded. I do this by this code

dsAlarms.AcceptChanges()
GridEXAlarms.UpdateData()
daAlarms.Update(dsAlarms)

For some reason at AcceptChanges the value recorded in ForeColor and BackColor (changed when the colors are changed) reset to DBNull.

Anybody any idea why?? Spent 2-3 hrs on this now. Your help would be most appreciated.

Best Rgds

Rob
0
Comment
Question by:RobKearney
8 Comments
 
LVL 27

Expert Comment

by:planocz
ID: 12066450
try this...
 
daAlarms.Update(DS.Tables("MYTableName"))
0
 
LVL 4

Expert Comment

by:gdexter
ID: 12066624
Do not Acceptchanges before an update

Rearange to

daAlarms.Update(dsAlarms)
dsAlarms.AcceptChanges()
GridEXAlarms.UpdateData()
0
 

Author Comment

by:RobKearney
ID: 12067671
guys,

Gave your two ideas a try.

planocz - Gave it a try, still causes the same crash at Update command.

gdexter - recognise that AcceptChanges appears after Update. Thank you!. Problem is, like I mentioned to planocz, it's the Update command that causes the problem. It doesn't even show an error message when it crashes.

I've done this on several other forms and works fine, it's only this form that causes problem and I think it's the fact that it's binding to TWO tables in the DataAdapter thats the problem.

Think it's a limitation of updating to TWO tables throught the dataAdapter. I had to create my own Update SQL in the DataAdapter that looked like this.

UPDATE Tbl_Alarms SET ForeColor = ?, BackColor = ? WHERE (AlarmRefNo = ?)

How about simply running an UPDATE sql statement to do the update (in code) to the table. Are there any issues in data integrity??

Thanks guys!!
Rob
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 27

Expert Comment

by:planocz
ID: 12067771
0
 

Author Comment

by:RobKearney
ID: 12301094
Didn't really get an breaks from the guys posts, even tough I was most appreciative of their support. Thank you!

I ended up solving the problem myself by running a INSERT INTO sql statement in the code that wrote back to the Tables in question.

Would I be able to get a refund, since it's a reasonable 250 pts allocated that I could save for a future post.


0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 12327307
PAQed, with points refunded (250)

Computer101
E-E Admin
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
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.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

758 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now