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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dataset just will not update

Status
Not open for further replies.

BrianB

Programmer
Oct 2, 2000
186
US
Hi folks,

Again, I am trying to get VB.Net to do things I used to do in VB6, and as, usual, it has left me exasperated and sputtering curses.

The culprit, as usual, is ADO.NET.

I am having some trouble with dataset binding.

I have a form with a couple of text boxes for FirstName, MiddleName, and LastName.
I have a dataset dimensioned at the module level that pulls data in from MSSQL.

I open the dataset and I ask it for LastName
MsgBox(mdstMyData.Tables(0).Rows(0).Item("LastName")) 'returns "Jones"

I bind firstname, lastname, and middlename to the dataset:

Me.LastName.DataBindings.Add("Text", mdstMyData.Tables(0), "LastName")

I change the data from "Jones" to "Smith". The changes appear on the form.

I press "Save" and the following code executes:
MsgBox(mdstMyData.Tables(0).Rows(0).RowState = DataRowState.Modified) 'returns false even though I can plainly see that the data changed

MsgBox(mdstMyData.Tables(0).Rows(0).Item("LastName")) 'returns "Smith" exactly as the form looks
MsgBox(mdstMyData.Tables(0).Rows(0).RowState = DataRowState.Modified) ' still returns false
mdstMyData.Tables(0).Rows(0).Item("LastName") = "Give us back ADO" 'I change the value in code
MsgBox(mdstMyData.Tables(0).Rows(0).Item("LastName")) 'returns "Give us back ADO" - I appear to have changed the Dataset
MsgBox(mdstMyData.Tables(0).Rows(0).RowState = DataRowState.Modified) 'still returns false

Any ideas?

-Brian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top