-
DataGrid problem
hi all..
i'm just a beginner in vb.net..so i need a solution for a problem..what i'm trying to do is show all the records in a table in a datagrid. it works fine the first time..but when i click on the button that does this again, the grid has duplicate values..so if the button is pressed thrice..the records are repaeated 3 times. so how do i stop this ??
Code:
myAdapter = New OleDbDataAdapter("select * from Login", dbConn)
myAdapter.Fill(ds, "Login")
grdDetails.DataSource = ds
here myAdapter is a DataAdapter n ds is a DataSet.
any help will be appreciated...thnx a lot
-
set the dataset to a new instance every time you click the button, i.e. in the button click event
myDataset = new Dataset
-
thnx...it helped
but now i have another problem....
i'm trying to update the database thru the datagrid i.e. on the click of 'Update' button..i save the changes made in the datagrid.
for this purpose i've used the update method of the dataadapter
Code:
myAdapter.Update(ds)
where myAdapter is a OleDbDataAdapter, ds=dataset
i've filled in the myadapter on the click of 'Display button'..the code is in my first thread . so cud u plz tell me how do i update..coz this is showing an error.
-
Here amNewatVB this might help you to understand.
Click Here