PC Review


Reply
Thread Tools Rate Thread

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

 
 
Paulo
Guest
Posts: n/a
 
      27th May 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.aspx.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
 
      27th May 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.aspx.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
 
      27th May 2008
On May 27, 11:45*am, "Paulo" <eris_pa...@terra.com.br> 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.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.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
Rate This Thread
Rate This Thread:

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
Vb.net 2008 - System.data.enumerablerowcollection(of system.data.datarow) convert to string??? Rob W Microsoft VB .NET 7 26th Nov 2009 05:09 PM
convert DataRow col value to enum type John A Grandy Microsoft C# .NET 1 24th Sep 2008 02:52 AM
How can I convert System.Type variables to some database data type? lichaoir Microsoft C# .NET 0 12th Mar 2008 03:35 AM
Cannot implicitly convert type 'object' to 'System.Xml.XmlDocument' Error Patrick Olurotimi Ige Microsoft ASP .NET 3 4th May 2005 06:21 AM
Anyway to convert an object type using a System.Type? Don Microsoft VB .NET 2 11th Apr 2005 08:39 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:02 AM.