Fill and Clear methods of data adapter

B

Brian Henry

If you have a data set, and it has a table which was created using the
fillschema method of the dataadapter. Do you have to clear the data table
each time you refill it? At first I thought you had to preform a clear each
time (by the way my table does have primary keys and is an auto increment pk
from sql server 2000) In the past I remembered if i didnt clear it and ran
fill again to fill a datatable in a dataset, it would then have duplicate
records in the datatable. I just however noticed when messing around, if i
disabled the clear on my current project (it was takeing a heck of a long
time to clear the tables, the clear method doesnt seem to fast) it isn't
creating duplicate records in the data tables. Is this because of the PK
constraint of the data? What is causing this to happen two different ways
between my past experience and current one? thanks!
 
B

Brian Henry

here's an example of one that doesn't need cleared.. the table has an auto
increment primary key in sqlserver...

Dim dsJournal As New DataSet

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Me.SqlDataAdapter1.FillSchema(dsJournal, SchemaType.Source,
"JournalEntryID")

Me.DataGrid1.DataSource = dsJournal.Tables("JournalEntryID")



End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Me.SqlDataAdapter1.Fill(dsJournal, "JournalEntryID")



End Sub





but some other times when I don't do the fill schema method, it will just
duplicate records over and over again... just doing a normal fill alone with
out it... if someone could explain how this fill produces two different
results to me i'd love it thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top