|
-
Mar 22nd, 2010, 06:13 PM
#1
Thread Starter
Hyperactive Member
Data Bindings lost during Fill
Hi all.
I'm having a rather irritating problem that I haven't been able to trace. I've been using a Table Adapter to fill out a Datagridview and DataBindings to fill out a number of labels.
This was working fine until a recent change, where I added three more columns to the database and updated the code to match.
Now, when I insert a new record and use a custom Fill command (the Fill command contains a simple WHERE X == ?), all my databound labels reset to blank "", and my datagridview doesn't show the new changes.
The Insert command doesn't cause the labels to blank out when the Fill command is commented, so it must be the latter causing this behaviour. I have verified this by adding a button that does nothing but call that Fill command. Oddly, the exact same custom fill command is used during Form_Load to fill the datagrid view, and it works fine there: just not any time after that.
In the interests of providing all the information:
C# Pro 2008. Access 2003 *.mdb database. OleDb Connection. Designer-built dataSet.
The datagridview and data bound labels, as well as their Table Adapter and Binding Source are all on a custom form, which is created from the main form using ImpactTableEditing dlog = new ImpactTableEditing(). (The form is purely for the purposes of editing and viewing information in the table in question). The main form also has a copy of the ImpactTableBindingSource, for less detailed info viewing.
The SQL for the Fill command in question:
Code:
SELECT [ImpactTable].*
FROM [ImpactTable]
WHERE ([Impact Parent ID] = ?)
The data bindings to the labels are added immediately after the Fill command in the Load method:
Code:
ImpIDLbl.DataBindings.Add("Text", ImpactTableBindingSource, "ID");
I've deleted the table adapter and re-made it, I've checked thoroughly for any changes beyond the three new columns, I've removed all database relations, and I've re-instated the back-up file to check it and look for differences (it still works without a problem, and the only differences I can find in it are related to the three new columns).
The three new columns are two DateTime fields and a single long integer.
I am extremely frustrated with this. I think I may have permanently damaged my keyboard with my head. Or possibly the other way around. Any help or suggestions would be sincerely appreciated.
Thanks!
Qu.
Last edited by Quasar6; Mar 22nd, 2010 at 06:16 PM.
"Why do all my attempts at science end with me getting punched by batman?" xkcd.
| Pong| |
Sorry for not posting more often.
-
Mar 22nd, 2010, 06:47 PM
#2
Thread Starter
Hyperactive Member
Re: Data Bindings lost during Fill
Ah, I've found a workaround, so this no longer has the urgency it did. I need an emoticon for "slowly coming down from the heights of frustration."
Long story short: I cleared the databindings from the labels before, and re-instated them after, each Fill command, so my fill commands now look like this:
Code:
Label1.DataBindings.Clear();
Label2.DataBindings.Clear();
//etc.
this.ImpactTableAdapter.FillByImpactName(this.dataSet.ImpactTable, CurrentParentName);
Label1.DataBindings.Add("Text", impactTableBindingSource, "ID");
Label2.DataBindings.Add("Text", impactTableBindingSource, "Name");
//etc.
I see no reason this would suddenly become necessary, however. Any information you can provide would be valuble. This workaround would be a lot of work if a similar thing occured on my main-form, so I'd really like to know what caused it so I can avoid triggering the problem again.
Thank you!
Qu.
"Why do all my attempts at science end with me getting punched by batman?" xkcd.
| Pong| |
Sorry for not posting more often.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|