Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 6th, 2007, 07:19 AM
Registered User
 
Join Date: Jun 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default DataRow.ItemArray

Hi,
I get an itemarray back with all types as System.DBNull and the following line assignment does not work:
Code:
for (DataRow row in table.Rows)
{

   row.ItemArray[10]="some string";
}
I have also tried using the following and that does not work either

Code:
for (DataRow row in table.Rows)
{
   row.BeginEdit();
   row.ItemArray.SetValue("some string",10);
   row.EndEdit();
}

Please suggest a solution

 
Old June 6th, 2007, 01:16 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

row.ItemArray[10] = "some string"; is a boolean evaluation. Where as row.ItemArray[10] == "some string"; is an assignment

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
 
Old June 6th, 2007, 03:00 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Not sure what language this is:
Quote:
quote:row.ItemArray[10] = "some string"; is a boolean evaluation. Where as row.ItemArray[10] == "some string"; is an assignment
but I'd say it's the other way around....

abhi123: it seems your for loop isn't correct; you either need a foreach loop on items or a for with a counter.

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
 
Old June 6th, 2007, 07:44 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

>< Imar is correct, that will teach me to take 2 weeks off, bah!

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
 
Old June 7th, 2007, 02:33 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

;) Time for a holiday.....

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to add a DataRow to a DataSet? jhansib4u ADO.NET 1 January 8th, 2008 09:36 AM
Need help understanding DataRow asp_convert ADO.NET 3 March 13th, 2007 02:39 PM
insert datarow into datagrid lpl General .NET 1 March 29th, 2006 07:05 AM
how to add a dataRow[] into a datatable sendtogary VS.NET 2002/2003 0 March 27th, 2006 05:32 AM
deleting a datarow sand133 VB Databases Basics 0 July 14th, 2004 07:08 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.