find method from dataview fail

pamtru

New member
Joined
Feb 5, 2007
Messages
2
Programming Experience
1-3
Hi!. i am doing a winform to add,modify and remove users from a mysql database. At form load i fill a dataset with all the users that are in the database, then i made a simple navigation system with 2 buttons (prev and next) and a textbox telling the number of record you are on. I also have a find button that opens a modal form which has a datagrid filled by a query. When you do dbclick to a cell the modal form returns the userId that you have select. After that i do this

dataset.tables("xxx").defaultview.sort="ID"
position=dataset.tables("xxx").defaultview.find(selectedID)
updatePosition(position)

this works great, but it fails if before searching you add or remove records. When adding a record i dont reload the dataset i only add the record to the database and the dataset this way.
obDataset.Tables("xxx").Rows.Add(obCartRow) ' here in the dataset
obCarteros.insertUser(obTemp) ' here in database by calling a store procedure.

the same for removing. if i reload the dataset before searching it works but i dont want to do that, i only want the position of the record.
Anybody can help me???.

thanks!!!!!
Pamela
 
Sorry i forgot to say that it fails because it doesnt give me the record i have selected (the modal form gave me the correct id).Thanks!!
 
i'm not sure this will work.. there's just too much wrong with it, including making assumptions that the id will sort, that it will relate to the row or position and that the position will be assignable from an array of datarows..

Instead, you should just pass the original bindingsource to the modal form and use the fact that selecting an item in the grid will update the bindingsource position

to exmaple what I mean I will post a sample project..
 
Back
Top