locked
TableAdapter retrieve row conversion issue RRS feed

  • Question

  • User1810061435 posted

    thanks for your time!
    what I am doing possibly wrong! I use the two code sequences in same App but different .aspx.cs files.
     The first gives below error; the 2nd runs just fine!
    RegID shows the correct string!

    The same 'using' statements are used! The TableAdapter is obviously the same ....
    ? what simple thing might I miss?
    thanks again for your time and help
    ed

    -------------------------------
    ERROR CS0029: Cannot implicitly convert type 'DataSetASGB.namesDataTable' to 'DataSetASGB.namesRow'
      string RegID;
            int IDRegID;
            DataSetASGB DataSetASGB = new DataSetASGB();
            DataSetASGBTableAdapters.namesTableAdapter daN= new DataSetASGBTableAdapters.namesTableAdapter();

            RegID = GridViewMemberUser.Rows[e.RowIndex].Cells[1].Text;
            DataSetASGB.namesRow row;
            row = daN.GetDataByRegID(RegID); <====== error, 'daN' blue underscored!

            IDRegID = row.idNames;

    -------------------------------
      DataSetASGB DataSetASGB = new DataSetASGB();
            DataSetASGBTableAdapters.namesTableAdapter daN = new DataSetASGBTableAdapters.namesTableAdapter();

            // update record in case membership has changed
             
                DataSetASGB.namesRow row;

                row = daN.GetDataByRegID(m.UserName)[0];

                row.Role = members[0];
                row.RegID = m.UserName;

    Friday, December 24, 2010 4:39 PM

Answers

  • User2497035 posted

    Hi there,

    The error is caused because the GetDataByReqID is returning a datatable and you're trying to save the datatable

    in a row.The second one is working because you are specify that you want to get row at index [0]. The RegID is

    probably unique and you are expecting just a single row to be returned, but still that row will be returned inside a DataTable.

    .Just do it the same way you did the second one.




    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, December 24, 2010 10:04 PM
  • User1810061435 posted

    Hi Bassam,

    ... oops! Thank you very much ... I should have known ! Was probably to late or early..

    Thanks for your time all is fine now

    ed

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, December 25, 2010 3:22 AM

All replies

  • User2497035 posted

    Hi there,

    The error is caused because the GetDataByReqID is returning a datatable and you're trying to save the datatable

    in a row.The second one is working because you are specify that you want to get row at index [0]. The RegID is

    probably unique and you are expecting just a single row to be returned, but still that row will be returned inside a DataTable.

    .Just do it the same way you did the second one.




    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, December 24, 2010 10:04 PM
  • User1810061435 posted

    Hi Bassam,

    ... oops! Thank you very much ... I should have known ! Was probably to late or early..

    Thanks for your time all is fine now

    ed

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, December 25, 2010 3:22 AM