I have seen several postings on this error, but I can't seem to make the answers fit my problem.
Generally, it is a simple dgv load with a simple query. The error I get is:
Error: System.ArgumentOutOfRangeException: Index was out of range. Here is the code:
The first time thru the code, it throws the error on "dgvSQL.DataSource = bsSQLData"
The subsequent times thru the same code, it fails on "bsSQLData.DataSource = ds.Tables[0]" and throws the error twice.
I am baffled! I have tried several different ways to load the grid. Same result.
The grid DOES still load, but with the error that must be acknowledged.
My grid is set to readonly. I just did not think there was anything fancy here!
I would appreciate any thoughts.
Generally, it is a simple dgv load with a simple query. The error I get is:
Error: System.ArgumentOutOfRangeException: Index was out of range. Here is the code:
C#:
string sSQL =
"select * from Table ORDER BY FieldFK";
DataClass dbName = new DataClass(sDBConnection);
dbName.OpenConnection();
//Load the data to the screen.
SqlDataAdapter sda = dbName.ExecuteAdapter(sSQL); //
DataSet ds = new DataSet();
sda.Fill(ds);
bsSQLData.DataSource = ds.Tables[0];
dgvSQL.DataSource = bsSQLData;
The first time thru the code, it throws the error on "dgvSQL.DataSource = bsSQLData"
The subsequent times thru the same code, it fails on "bsSQLData.DataSource = ds.Tables[0]" and throws the error twice.
I am baffled! I have tried several different ways to load the grid. Same result.
The grid DOES still load, but with the error that must be acknowledged.
My grid is set to readonly. I just did not think there was anything fancy here!
I would appreciate any thoughts.