473,408 Members | 1,857 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

A very simple question about assigning a value

Hello,

I have the following case where I want to assign a value to a column
in a row. But it gives me an error that "Property Item is readonly":

DataAdapter.Fill(DataTable1)

Dim clone as DataTable

clone = DataTable1.Clone

For Each row As DataRow In
DataTable1.Select(String.Format("{0}='{1}'", field1, somevalue))

clone.ImportRow(row)

Next

clone.Rows.Item("field2") = "Test"
Here is the problem where it says "Property Item is readonly"

Your kind help will be really appreciated.

cheers

SY
Nov 22 '05 #1
4 1670
You have to do it this way:

clone.Rows(RowNumber)("field2") = "Test"

The "Rows" is the collection of all rows in the table (index starts at 0).
So you have to access one row in the way above by replacing "RowNumber" by
the number of the row in which you wanna assign the value to the field.

Regards,

Peter

"Sajid" <sa*********@yahoo.com> schrieb im Newsbeitrag
news:e0**************************@posting.google.c om...
Hello,

I have the following case where I want to assign a value to a column
in a row. But it gives me an error that "Property Item is readonly":

DataAdapter.Fill(DataTable1)

Dim clone as DataTable

clone = DataTable1.Clone

For Each row As DataRow In
DataTable1.Select(String.Format("{0}='{1}'", field1, somevalue))

clone.ImportRow(row)

Next

clone.Rows.Item("field2") = "Test"
Here is the problem where it says "Property Item is readonly"

Your kind help will be really appreciated.

cheers

SY

Nov 22 '05 #2
You have to do it this way:

clone.Rows(RowNumber)("field2") = "Test"

The "Rows" is the collection of all rows in the table (index starts at 0).
So you have to access one row in the way above by replacing "RowNumber" by
the number of the row in which you wanna assign the value to the field.

Regards,

Peter

"Sajid" <sa*********@yahoo.com> schrieb im Newsbeitrag
news:e0**************************@posting.google.c om...
Hello,

I have the following case where I want to assign a value to a column
in a row. But it gives me an error that "Property Item is readonly":

DataAdapter.Fill(DataTable1)

Dim clone as DataTable

clone = DataTable1.Clone

For Each row As DataRow In
DataTable1.Select(String.Format("{0}='{1}'", field1, somevalue))

clone.ImportRow(row)

Next

clone.Rows.Item("field2") = "Test"
Here is the problem where it says "Property Item is readonly"

Your kind help will be really appreciated.

cheers

SY

Nov 22 '05 #3
Ok this is easy.

Your trying to assign a value to a row position not the actual column, or
better the cell.

Off the top of my head:

clone.Rows[index].Columns[index].Text = "Test"

Mind you this syntax is probably wrong but you should get the idea.

Enjoy!!

-Evan

"Sajid" <sa*********@yahoo.com> wrote in message
news:e0**************************@posting.google.c om...
Hello,

I have the following case where I want to assign a value to a column
in a row. But it gives me an error that "Property Item is readonly":

DataAdapter.Fill(DataTable1)

Dim clone as DataTable

clone = DataTable1.Clone

For Each row As DataRow In
DataTable1.Select(String.Format("{0}='{1}'", field1, somevalue))

clone.ImportRow(row)
Ok
Next

clone.Rows.Item("field2") = "Test"
Here is the problem where it says "Property Item is readonly"

Your kind help will be really appreciated.

cheers

SY

Nov 22 '05 #4
Ok this is easy.

Your trying to assign a value to a row position not the actual column, or
better the cell.

Off the top of my head:

clone.Rows[index].Columns[index].Text = "Test"

Mind you this syntax is probably wrong but you should get the idea.

Enjoy!!

-Evan

"Sajid" <sa*********@yahoo.com> wrote in message
news:e0**************************@posting.google.c om...
Hello,

I have the following case where I want to assign a value to a column
in a row. But it gives me an error that "Property Item is readonly":

DataAdapter.Fill(DataTable1)

Dim clone as DataTable

clone = DataTable1.Clone

For Each row As DataRow In
DataTable1.Select(String.Format("{0}='{1}'", field1, somevalue))

clone.ImportRow(row)
Ok
Next

clone.Rows.Item("field2") = "Test"
Here is the problem where it says "Property Item is readonly"

Your kind help will be really appreciated.

cheers

SY

Nov 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: JKop | last post by:
Take the following simple function: unsigned long Plus5Percent(unsigned long input) { return ( input + input / 20 ); } Do yous ever consider the possibly more efficent:
5
by: disco | last post by:
I am working on this example from a book "C Primer Plus" by Prata 4th edition - p. 672. There is no erata on this problem at the publisher's website. 1) Is it a violation of copyright laws to...
13
by: na1paj | last post by:
here's a simple linked list program. the DeleteNode function is producing an infinit loop i think, but i can't figure out where.. #include <stdio.h> typedef struct { char *str; //str is a...
5
by: Rob Somers | last post by:
Hey all I am writing a program to keep track of expenses and so on - it is not a school project, I am learning C as a hobby - At any rate, I am new to structs and reading and writing to files,...
1
by: Tim | last post by:
I can't seem to figure out why this very simple linked list wont build.. I mean, there is no intelligence, just add to end. Anyway, please let me know if something i can do will make head (the...
6
by: lovecreatesbeauty | last post by:
/* It seems that when an int with width of four bytes is assigned to a one byte width char, the first three bytes from left to right are discarded and the rightest byte is assigned to that char....
73
by: Claudio Grondi | last post by:
In the process of learning about some deeper details of Python I am curious if it is possible to write a 'prefix' code assigning to a and b something special, so, that Python gets trapped in an...
30
by: Brian Elmegaard | last post by:
Hi, I am struggling to understand how to really appreciate object orientation. I guess these are FAQ's but I have not been able to find the answers. Maybe my problem is that my style and...
4
by: Armand | last post by:
Hi Guys, I have a set of array that I would like to clear and empty out. Since I am using "Array" not "ArrayList", I have been struggling in finding the solution which is a simple prob for those...
30
by: galiorenye | last post by:
Hi, Given this code: A** ppA = new A*; A *pA = NULL; for(int i = 0; i < 10; ++i) { pA = ppA; //do something with pA
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.