Cannot convert type 'object[]' to 'System.Data.DataRow'

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Paulo

    Cannot convert type 'object[]' to 'System.Data.DataRow'

    DataRow dr = (DataRow)ds.Tab les[0].Rows[1].ItemArray;

    Error 1 Cannot convert type 'object[]' to 'System.Data.Da taRow' C:\Documents
    and Settings\Fabio\ Meus documentos\Visu al Studio
    2005\Projects\C odBarraPalm\Cod BarraPalm\Defau lt.aspx.cs 35 26 CodBarraPalm
    ?

    why this error trying to get the contents of a row on a DataSet?


  • Misbah Arefin

    #2
    Re: Cannot convert type 'object[]' to 'System.Data.Da taRow'

    if you want a single row just use

    DataRow dr = ds.Tables[0].Rows[1];


    --
    Misbah Arefin







    "Paulo" <eris_paulo@ter ra.com.brwrote in message
    news:ecuLboCwIH A.3760@TK2MSFTN GP04.phx.gbl...
    DataRow dr = (DataRow)ds.Tab les[0].Rows[1].ItemArray;
    >
    Error 1 Cannot convert type 'object[]' to 'System.Data.Da taRow'
    C:\Documents and Settings\Fabio\ Meus documentos\Visu al Studio
    2005\Projects\C odBarraPalm\Cod BarraPalm\Defau lt.aspx.cs 35 26 CodBarraPalm
    ?
    >
    why this error trying to get the contents of a row on a DataSet?
    >
    >

    Comment

    • Norm

      #3
      Re: Cannot convert type 'object[]' to 'System.Data.Da taRow'

      On May 27, 11:45 am, "Paulo" <eris_pa...@ter ra.com.brwrote:
      DataRow dr = (DataRow)ds.Tab les[0].Rows[1].ItemArray;
      >
      Error 1 Cannot convert type 'object[]' to 'System.Data.Da taRow' C:\Documents
      and Settings\Fabio\ Meus documentos\Visu al Studio
      2005\Projects\C odBarraPalm\Cod BarraPalm\Defau lt.aspx.cs 35 26 CodBarraPalm
      ?
      >
      why this error trying to get the contents of a row on a DataSet?
      This error is because you are refering to the ItemArray. ItemArray
      returns an array of objects that contains the values of each column in
      the DataRow by ordinal. Simply remove the ".ItemArray " and that will
      work.

      DataRow dr = (DataRow)ds.Tab les[0].Rows[1];

      In the future, you might want to actually look at the error
      description. It specifically says that it can't convert an array of
      objects "object[]" to a DataRow.
      Happy coding!

      Comment

      Working...