Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Cannot convert type 'object[]' to 'System.Data.DataRow'

Reply
Thread Tools

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

 
 
Paulo
Guest
Posts: n/a
 
      05-27-2008
DataRow dr = (DataRow)ds.Tables[0].Rows[1].ItemArray;

Error 1 Cannot convert type 'object[]' to 'System.Data.DataRow' C:\Documents
and Settings\Fabio\Meus documentos\Visual Studio
2005\Projects\CodBarraPalm\CodBarraPalm\Default.as px.cs 35 26 CodBarraPalm
?

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


 
Reply With Quote
 
 
 
 
Misbah Arefin
Guest
Posts: n/a
 
      05-27-2008
if you want a single row just use

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


--
Misbah Arefin
https://mcp.support.microsoft.com/profile/MISBAH.AREFIN
http://dotnethitman.spaces.live.com
http://www.linkedin.com/in/misbaharefin




"Paulo" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> DataRow dr = (DataRow)ds.Tables[0].Rows[1].ItemArray;
>
> Error 1 Cannot convert type 'object[]' to 'System.Data.DataRow'
> C:\Documents and Settings\Fabio\Meus documentos\Visual Studio
> 2005\Projects\CodBarraPalm\CodBarraPalm\Default.as px.cs 35 26 CodBarraPalm
> ?
>
> why this error trying to get the contents of a row on a DataSet?
>
>

 
Reply With Quote
 
 
 
 
Norm
Guest
Posts: n/a
 
      05-27-2008
On May 27, 11:45*am, "Paulo" <(E-Mail Removed)> wrote:
> DataRow dr = (DataRow)ds.Tables[0].Rows[1].ItemArray;
>
> Error 1 Cannot convert type 'object[]' to 'System.Data.DataRow' C:\Documents
> and Settings\Fabio\Meus documentos\Visual Studio
> 2005\Projects\CodBarraPalm\CodBarraPalm\Default.as px.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.Tables[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!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compiler Error Message: CS0030: Cannot convert type 'ASP.login_aspx' to 'System.Web.UI.WebControls.Login' keithb ASP .Net 2 05-31-2006 07:21 PM
Cannot convert type 'ASP.login_aspx' to 'System.Web.UI.WebControls.Login' Tim Cartwright ASP .Net 6 11-13-2005 08:47 PM
Cannot implicitly convert type 'object' to 'System.Xml.XmlDocument' Error Patrick Olurotimi Ige ASP .Net 3 05-04-2005 05:21 AM
cannot implicitly convert type object to string Andy Sutorius ASP .Net 9 02-22-2005 04:19 PM
Cannot implicitly convert type 'object' to 'bool' Error Patrick Olurotimi Ige ASP .Net 2 01-25-2005 02:13 AM



Advertisments