473,383 Members | 2,005 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,383 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 1667
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
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.