jlwilliams1
Member
- Joined
- Mar 15, 2005
- Messages
- 5
- Programming Experience
- 1-3
I'm writing a windows service that periodically goes out to a SQL table and checks it for new records. I connect ok and fill the dataset ok, but how do I clear the dataset once I'm done with it? What's happening is that evertime the service goes to check the table, it fills the dataset, appending from the end. So if I start with 2 new records in the dataset, at the next check the dataset will have 4, then 6, etc.
I've tried using dataset.clear and dataset.Tables("tablename").Rows.Clear(), but neither seems to work.
Any clues or ideas?
Here's the code I'm using:
I've tried using dataset.clear and dataset.Tables("tablename").Rows.Clear(), but neither seems to work.
Any clues or ideas?
Here's the code I'm using:
VB.NET:
SelectStatement = "SELECT * FROM Test WHERE Newrecord = 'Y'" cmd.CommandText = SelectStatement
cmd.CommandType = CommandType.Text
cmd.Connection = connect
da.SelectCommand = cmd
connect.Open()
ds.Clear()
da.Fill(ds, "Test")
If ds.Tables(0).Rows.Count <= 0 Then
da.SelectCommand.Connection.Close()
Exit Sub
End If
connect.Close()
numrecs = ds.Tables(0).Rows.Count