I can't seem to get this to work, I must be missing something.
I get this Error when I attempt to replace the ID value with the Name.
Error: System.FormatException: Input string was not in a correct format. at
System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
at System.String.System.IConvertible.ToInt32(IFormatP rovider provider) at
System.Convert.ToInt32(Object value) at
System.Data.Common.Int32Storage.Set(Int32 record, Object value) at
System.Data.DataColumn.set_Item(Int32 record, Object value)Couldn't store in
Concern_EnteredID Column. Expected type is Int32.
Using (and I have tried converting row with no success):
Dim i As Integer
Dim rowcount As Integer = ds.Tables(0).Rows.Count
For i = 0 To rowcount - 1
Dim enteredbyid As Integer =
ds.Tables(0).Rows(i)("Concern_EnteredID")
Dim enteredbyname As String =
qc2005s.GetName(enteredbyid)
Convert.ToString(ds.Tables(0).Columns(2).ToString( ))
ds.Tables(0).Rows(i)("Concern_EnteredID") = enteredbyname
Next i
Thanx for your help.
"Cowboy (Gregory A. Beamer)" wrote:
Non-strongly typed, I assume:
VB.NET
---------
1Can also use ordinal value for table, like ds.Table(0)
ds.Table("TableName").Row(0)("EnteredByID") = 11
ds.Table("TableName").Row(0)("EnteredByName") = "John Smith"
C#
----
//Can also use ordinal value for table, like ds.Table[0]
ds.Table["TableName"].Row[0]["EnteredByID"] = 11;
ds.Table["TableName"].Row[0]["EnteredByName"] = "John Smith";
The biggest issue is finding the correct row. You can, if you desire, run
through the rows:
C#
---
foreach (DataRow dr in ds.Table[0].Rows)
{
if(dr["EnteredByID")==12)
{
dr["EnteredByID"] = 11;
dr["EnteredByName"] = "John Smith";
}
}
Hope this helps.
--
Gregory A. Beamer
MVP; MCP: +I, SD, SE, DBA
*************************************************
Think outside the box!
*************************************************
"Chris" <Ch***@discussions.microsoft.com> wrote in message
news:7A**********************************@microsof t.com... I have a dataset that I want to modify the values in a particular column.
I.e if I have a function to convert the enterbyID (Integer) to a name, in the
dataset the field (Concern_EnteredbyID) shows as the integer. How can I
modifiy the dataset (ds) before I do something else with it?
I've read many posts but without success. Thanx.
Concern_EnteredByID I want (I have the function to pass the
value to)
12 Joe Smith
11 John Smith
Also is there a way to also alter the header info (the ds column name)?
Thanx.