Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bound Textbox - Database update problem

Status
Not open for further replies.

Draug

Programmer
Apr 18, 2001
77
CA
Greetings,

I have a textbox that is bound to a dataset. The dataset is populated by a data adapter which pulls data from a table in the database.

When I change the value in the textbox, I cannot get that change to be recorded in the database. It looks to me like what I have done should work; here it is:

'fill my dataset
daPS.Fill(DsPS1)
'bind the textbox to the field in the dataset
txtArea.DataBindings.Add("Text", DsPS1.Tables("Project_Summary"), "Project_Area")

'later (in the close event), after changes were entered
dsChanges = DsPS1.GetChanges()
'Update dataset
daPS.Update(dsChanges)

For some reason, the GetChanges() is returning nothing, even though I changed the box contents. Why?

Is there a better way to bind a textbox to a table field?

The only thing I can think of that is a little odd, is that the type of my data in the textbox is text, but it is numeric in the database. Could that cause my problem?

Thanks for any help,
Draug
 
Yeah, I have learned that is has something to do with the Edit of the current record not ending at point of leaving a box. From a dataset point of view, that record is still being editted.

I fixed that by adding this before getChanges:

Dim bmPS As BindingManagerBase
bmPS = BindingContext(dsPS1, "Project_Summary")bmPS.EndCurrentEdit()

Hope this helps someone.

Draug
 
So what is getChanges? Is it your function? Can you please post the answer?
 
getChanges() is a built in method of the dataset class. It retrieves the changes made on a dataset during that edit session. There is hasChanges() and acceptChanges(), and maybe more.
 
Thanks. I'm just learnuing the .NET world. I wish I did not know VB6 so I would not have such a learning curve. LOL
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top