Solved

Cannot Update a change to DB Table

Posted on 2004-09-15
8
317 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

726 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