Today is my first day on this site. I am vey new to VB.NET, i have a good amount of experience in VB6. I have a application I wrote for my Aikido club to track hours and I am converting it to .NET. The code below is very basic and works fine. However I want to change the granularity of the Sql search to:

Sql = "Select Aikidomember.lname,Aikidomember.fname,Aikidomember.ranking,Aikidomember.lasttest from Aikidomember Where S_Status = 'Active' order by Aikidomember.lname"

So I tried to make it as simple as possible, I took all of the code below, put it in a button, changed the Sql statement.
The Below code returns 120 students. When I use the above Sql it SHOULD return 38, however it returns 158! to it is just appending the new data. I have tried using con.dispose instead of close and no luck.... Help! :)

dbProvider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
        dbSource = "Data Source = C:/Aikido/AikidoResources.mdb"
        con.ConnectionString = dbProvider & dbSource
        Sql = "Select Aikidomember.lname,Aikidomember.fname,Aikidomember.ranking,Aikidomember.lasttest from Aikidomember order by Aikidomember.lname"
        da = New OleDb.OleDbDataAdapter(Sql, con)
        da.Fill(ds, "AikidoMember")
        MaxRows = ds.Tables("AikidoMember").Rows.Count
        TotalCnt.Text = MaxRows
        inc = -1

It looks like you are filling a datatable within the dataset that already exists. You're reusing the same datatable, is that correct? You need to either clear the existing data from that datatable or remove the datatable from the dataset altogether before you call the Fill operation again.



This article has been dead for over six months. Start a new discussion instead.