Results 1 to 4 of 4

Thread: DataGrid problem

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2003
    Location
    Delhi, India
    Posts
    47

    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

  2. #2
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Reading, UK
    Posts
    870
    set the dataset to a new instance every time you click the button, i.e. in the button click event

    myDataset = new Dataset
    www.vb-tech.com
    .Net Freelance Development
    http://weblog.vb-tech.com/nick
    My blog

  3. #3

    Thread Starter
    Member
    Join Date
    Dec 2003
    Location
    Delhi, India
    Posts
    47
    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.

  4. #4
    New Member robinhood1995's Avatar
    Join Date
    Jan 2004
    Location
    Cincinnati, OH
    Posts
    1
    Here amNewatVB this might help you to understand.

    Click Here
    One who asks is only laughed at for 5 minutes,
    the one who doesn't ask is in the dark for life.
    www.myfflbook.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width