show dataset in datagrid

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

my problem is duplicating records


for example i have this records in dataset first

name stundentno
----------------------- -------------------------
SAM 1
GEORGE 2



AFTER ADDING A NEW RECORD



name stundentno
----------------------- -------------------------
NICHOLAS 3





then i saw in datagrid like this


name stundentno
------------- ---------- -------------------------
SAM 1
GEORGE 2
SAM 1
GEORGE 2
NICHOLAS 3



stok.name = txtname.Text
stok.stundentno = txtstundentno.Text








Private Sub btnEkle_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEkle.Click

'adding

stok.MinNoGecici()

stok.con.Open()
stok.MinNoGeciciSqlInsertCMD.ExecuteNonQuery()
stok.con.Close()





stok.MinNoGecici()



stok.MinNoGeciciDA.Fill(stok.MinNoGeciciDS, "MinNoGecici")


DataGrid1.DataSource = stok.MinNoGeciciDS
DataGrid1.DataMember = "MinNoGecici"
DataGrid1.Refresh()
btnEkle.Enabled = False


end sub
 
Hi Bafidi,

First of all when you send code please post it first in a notebook and than
from that in the message.

Your problem,

As far as I can see you use a dataprocessing class that you made yourself
but are not using the dataadapter to do the "update".

I would not take that approach, but when you do that you have to create the
dataset as new everytime you do the fill. (Not that that new is time or
resource spending).

I would use the dataadapter update.

http://msdn.microsoft.com/library/d...conUpdatingDatabaseWithDataAdapterDataSet.asp

I do not find this a real nice sample, but have a look at it, when you use
the datagrid you have also to do before the update.

DirectCast(BindingContext(ds.Tables(0)), CurrencyManager).EndCurrentEdit()

And to become problems with making the update, insert and delete commands
you can use this, however it is buggy it seems.

http://msdn.microsoft.com/library/d.../html/cpconautomaticallygeneratedcommands.asp

I hope this helps?

Cor
 
Back
Top