Dataset and Arrays

Last post 12-04-2006 1:49 AM by klover79. 2 replies.

Sort Posts:

  • Dataset and Arrays

    11-30-2006, 10:05 PM
    • Loading...
    • klover79
    • Joined on 11-30-2006, 9:40 PM
    • Posts 6

    Hi all,

    I have an array of 4 elements, for each of these elements i would like to create a dataset for each. currently this is what i have. 

    answer8(0) = CheckBox1.Text
    answer8(1) = CheckBox2.Text
    answer8(2) = CheckBox3.Text
    answer8(3) = CheckBox4.Text
    answer8(4) = CheckBox5.Text

    For i = 0 to UBOUND(answers)

        str_counter = "SELECT [Count] FROM Answers WHERE Answers = '" & answer(i) & "'"
        da_counter = New Data.OleDb.OleDbDataAdapter(str_counter, conn)
        ds_counter = New Data.DataSet
        da_counter.Fill(ds_counter)
        tcount = ds_counter.Tables(0).Rows(0).Item(0) <----- error occurs here

    the first and second element in the array works fine ...but it reaches the third one it comes out with " There no row at position 0"

    any solution or suggestions for this? thanks
     

     

     

    Filed under: , ,
  • Re: Dataset and Arrays

    12-03-2006, 10:05 PM
    Answer
    • Loading...
    • yyy8347
    • Joined on 09-19-2006, 11:00 AM
    • Posts 703
     Hi~

    It seems ds_counter.Tables(0) returns no rows.

    You can try something like this to determine if Tables(0) returns rows:

      if  ds_counter.Tables(0).RowCount > 0 then
         tcount = ds_counter.Tables(0).Rows(0).Item(0)
      End if

    Hope it helps.

    Sincerely,
    Young Fang
  • Re: Dataset and Arrays

    12-04-2006, 1:49 AM
    • Loading...
    • klover79
    • Joined on 11-30-2006, 9:40 PM
    • Posts 6
    ok ill give it a try thanks Yes
Page 1 of 1 (3 items)
Microsoft Communities
Page view counter