Home All Groups Group Topic Archive Search About
Author
9 Jan 2006 12:35 PM
Kajal
Hi,

Can anyone pls help me, I am getting Cast  error as follows:

"System.InvalidCastException: Specified cast is not valid.

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 <System.Data.DataRow> in series_disp_seq Column. Expected type is
Int32."


My code is as follows:
-------------
sFilterSeriesID = "[Series ID] in (" & psSeriesList.Trim & ")" '
Creating expression for filter

adrExportTP = ds.Tables("ExportTP" & lCount).Select(sFilterSeriesID)'--
Datarow array

'Below -- Updating values to the datarow array

Dim iValue As Int32

iValue = 12121212

For iFindSeriesID = 0 To asFindSeriesID.GetUpperBound(0) 'looping arr
of CSV series id

sSeriesID = asFindSeriesID.GetValue(iFindSeriesID)

For iRowCtr = 0 To adrExportTP.GetUpperBound(0) 'looping arr of DT
series id

If sSeriesID.Trim = adrExportTP(iRowCtr).Item("Series ID") Then
'Mapping

MsgBox(sSeriesID.Trim.ToUpper & " = " & _

asFindSeriesID.GetValue(iFindSeriesID))

adrExportTP(iRowCtr).Item("Jan-2006") = iValue

Exit For

End If

Next

Next


'-- Load the changed datarow to DT

Try

Dim myRow As DataRow

ds.Tables("ExportTP" & lCount).BeginLoadData()

myRow = ds.Tables("ExportTP" & lCount).LoadDataRow(adrExportTP, True)

ds.Tables("ExportTP" & lCount).EndLoadData()

Catch ex As SqlException

MsgBox(ex.Message)

Catch ex As Exception

MsgBox(ex.Message)

End Try

-------------


I do not understand where am i going wrong, I am only changing the Data
of Col "Jan-2006" then why do i get this error.

Note: the series_disp_seq is the primary key

Thanks

AddThis Social Bookmark Button