DataSet Filling Out of Order
I am currently designed a bowling statistics keeping program with essentially nested tables located in Microsoft Access.
Game -> Series -> Bowler -> Group
Each Game has a column called seriesID to say what series it is part of, directly associated with the primary key of Series, each series has a bowlerID and so on.
I am writing my own primary keys to ensure they match the row number regardless of any deleted rows, so to allow easy indexing.
The problem is, at random I start reading the rows of the table into a dataset out of order.
For instance, today I tried to read in 26 bowlers, and the dataset looked like this.
ds.rows(0-11) = table.rows(0-11) 'Good
ds.rows(12) = table.rows(24)
ds.rows(13) = table.rows(25)
ds.rows(14-25) = table.rows(12-23) 'All very bad
I have no idea what is causing this. And it's not always the center rows that get displaced. I've had other times where ds.rows(0) = table.rows(last) and ds.rows = table.rows(n - 1) for n = 1..last. It's all really random.
The code I am using to fill the dataset is the following.
Is there a reason this shouldn't work, or would work how mine is sometimes?
It's a problem that comes up off and on, usually more so when I've added rows by hand to the database directly (I think), though I can't say that it hasn't happened when adding to the database in code. I have elimated the problem by erasing the table and starting over, but it usually pops up again later on.
I really need to solve this problem or my program can't be very reliable. If you don't understand why this is happening, any suggestions on simple fixes that might get around the problem rather than solve it?
Thanks
I am currently designed a bowling statistics keeping program with essentially nested tables located in Microsoft Access.
Game -> Series -> Bowler -> Group
Each Game has a column called seriesID to say what series it is part of, directly associated with the primary key of Series, each series has a bowlerID and so on.
I am writing my own primary keys to ensure they match the row number regardless of any deleted rows, so to allow easy indexing.
The problem is, at random I start reading the rows of the table into a dataset out of order.
For instance, today I tried to read in 26 bowlers, and the dataset looked like this.
ds.rows(0-11) = table.rows(0-11) 'Good
ds.rows(12) = table.rows(24)
ds.rows(13) = table.rows(25)
ds.rows(14-25) = table.rows(12-23) 'All very bad
I have no idea what is causing this. And it's not always the center rows that get displaced. I've had other times where ds.rows(0) = table.rows(last) and ds.rows = table.rows(n - 1) for n = 1..last. It's all really random.
The code I am using to fill the dataset is the following.
VB.NET:
Dim con as New OleDbConnection
con.ConnectionString = "database location"
con.Open()
Dim table As String = "Bowlers"
Dim da As New OleDbDataAdapter("SELECT * FROM " & table, con)
Dim ds As New DataSet
da.Fill(ds, table)
con.Close()
Is there a reason this shouldn't work, or would work how mine is sometimes?
It's a problem that comes up off and on, usually more so when I've added rows by hand to the database directly (I think), though I can't say that it hasn't happened when adding to the database in code. I have elimated the problem by erasing the table and starting over, but it usually pops up again later on.
I really need to solve this problem or my program can't be very reliable. If you don't understand why this is happening, any suggestions on simple fixes that might get around the problem rather than solve it?
Thanks
Last edited: