Error creating DataAdapter

  • Thread starter Thread starter Ben
  • Start date Start date
B

Ben

Hey,


I've got two threads running at a point in time which are generated by
this code.

Thread oTdFillOffices = new Thread(new ThreadStart(FillOffices));
oTdFillOffices.Name = "FillOffices";
oTdFillOffices.IsBackground = true;
this.oThreads.Add(oTdFillOffices);
oTdFillOffices.Start();
Thread.Sleep(10);

Thread oTdFillContacts = new Thread(new ThreadStart(FillContacts)); //#2
oTdFillContacts.Name = "FillContacts";
oTdFillContacts.IsBackground = true;
this.oThreads.Add(oTdFillContacts);
oTdFillContacts.Start();
Thread.Sleep(10);

Within the first thread (FillOffices), i get to this line of code and
get an error.

System.Data.SqlClient.SqlDataAdapter oAdapter = new
System.Data.SqlClient.SqlDataAdapter("SELECT ID,Office,Company FROM
Office", oConn);

The error being ... :

A first chance exception of type 'System.IndexOutOfRangeException'
occurred in system.data.dll

Additional information: There is no row at position 0.

When that error occurs, i always seem to be at the line marked by the #2
in the parent thread. So it hasn't actually started a third thread yet.

Anyone have any ideas? because I'm running out :)

Thanks!

Ben
 
hi,

Here you are trying to fetch or bind result using index. am i right. If so
please check the record avilability. what i mean is if you are trying to
access the resultset using index,then you need to make sure that data is
there or not. In some cases the result set may zero.

Next one more chance is try to use different dataadapter in both threds.
 
Back
Top