M
mikeb
To me, 'Data Conversion Failed' sounds like I'm matching the wrong data
types - but in all my code tracing and viewing data coming into my
database - its just doesn't seem to be the case.
I have a dataset loaded from a sqlserver stored procedure call. I'm then
taking that dataset and copying its contents to the sqlce database (code
sample below). It works up until the 10203rd row - and then it fails on
the cmd.ExecuteNonQuery() statement. I inserted the nested Try block to see
what happens after this one 'bad' row -- every insert fails following row
10203.
I check the emulator's memory status and all appears fine - this same error
happens on the actual device too.
I have a break in the code and check the row that is just preceding this row
causing the error - the data is exactly the same with the exception of one
column - and its the same number of characters.
There must be more to this "Data Conversion Failed" error??
:
:
'Create the table
sqlCreateTable.CommandText = "CREATE TABLE ppcVEKP (" & _
"ucc_exidv nvarchar (20), " & _
"trackno_signi nvarchar (20), " & _
"factory_lifnr nvarchar (10), " & _
"ffs_scnnr_id nvarchar (20), " & _
"carton_venum smallint, " & _
"ffs_crtn_size nvarchar (04), " & _
"ffs_scanned_pack_fl nvarchar (01), " & _
"ffs_chng_dttm datetime " & _
")"
sqlCreateTable.ExecuteNonQuery()
:
:
'Here's the code that fails after inserting the 10203rd row, and each row
following:
Public Function loadVEKP(ByVal ds As DataSet, Optional ByRef Counter As
Integer = 0, Optional ByVal errCounter As Integer = 0) As Boolean
Dim rtn As Boolean = False
Dim Rows() As DataRow
Try
Dim cmd As SqlCeCommand
SQLce_Connect()
Rows = ds.Tables(0).Select()
For i As Integer = 0 To (Rows.Length - 1)
cmd = cnSqlCe.CreateCommand()
cmd.CommandText = _
"INSERT INTO ppcVEKP (" & _
"ucc_exidv, " & _
"trackno_signi, " & _
"factory_lifnr, " & _
"ffs_scnnr_id, " & _
"carton_venum, " & _
"ffs_crtn_size, " & _
"ffs_scanned_pack_fl, " & _
"ffs_chng_dttm " & _
") " & _
"VALUES " & _
"(?,?,?,?,?,?,?,?)"
With Rows(i)
cmd.Parameters.Add("ucc_exidv", .Item("EXIDV"))
cmd.Parameters.Add("trackno_signi", .Item("SIGNI"))
cmd.Parameters.Add("factory_lifnr", .Item("LIFNR"))
cmd.Parameters.Add("ffs_scnnr_id", .Item("FFS_SCNNR_ID"))
cmd.Parameters.Add("carton_venum", .Item("VENUM"))
cmd.Parameters.Add("ffs_crtn_size", .Item("FFS_CRTN_SIZE"))
cmd.Parameters.Add("ffs_scanned_pack_fl",
..Item("FFS_SCANNED_PACK_FL"))
cmd.Parameters.Add("ffs_chng_dttm", .Item("FFS_CHNG_DTTM"))
End With
'Open the connection, execute the query
Try
cmd.Prepare()
cmd.ExecuteNonQuery()
Counter += 1
Catch SqlCeEx As SqlCeException
errCounter += 1
Finally
cmd.Dispose()
End Try
Next i
rtn = True
Catch SqlCeEx As SqlCeException
errorHandlerSQLce("An error occurred - Please report this error:
modGlobal.loadVEKP", SQLceex)
Catch ex As Exception
errorHandler("An error occurred - Please report this error:
modGlobal.loadVEKP", ex)
Finally
SQLce_Disconnect()
End Try
Return rtn
End Sub
types - but in all my code tracing and viewing data coming into my
database - its just doesn't seem to be the case.
I have a dataset loaded from a sqlserver stored procedure call. I'm then
taking that dataset and copying its contents to the sqlce database (code
sample below). It works up until the 10203rd row - and then it fails on
the cmd.ExecuteNonQuery() statement. I inserted the nested Try block to see
what happens after this one 'bad' row -- every insert fails following row
10203.
I check the emulator's memory status and all appears fine - this same error
happens on the actual device too.
I have a break in the code and check the row that is just preceding this row
causing the error - the data is exactly the same with the exception of one
column - and its the same number of characters.
There must be more to this "Data Conversion Failed" error??
:
:
'Create the table
sqlCreateTable.CommandText = "CREATE TABLE ppcVEKP (" & _
"ucc_exidv nvarchar (20), " & _
"trackno_signi nvarchar (20), " & _
"factory_lifnr nvarchar (10), " & _
"ffs_scnnr_id nvarchar (20), " & _
"carton_venum smallint, " & _
"ffs_crtn_size nvarchar (04), " & _
"ffs_scanned_pack_fl nvarchar (01), " & _
"ffs_chng_dttm datetime " & _
")"
sqlCreateTable.ExecuteNonQuery()
:
:
'Here's the code that fails after inserting the 10203rd row, and each row
following:
Public Function loadVEKP(ByVal ds As DataSet, Optional ByRef Counter As
Integer = 0, Optional ByVal errCounter As Integer = 0) As Boolean
Dim rtn As Boolean = False
Dim Rows() As DataRow
Try
Dim cmd As SqlCeCommand
SQLce_Connect()
Rows = ds.Tables(0).Select()
For i As Integer = 0 To (Rows.Length - 1)
cmd = cnSqlCe.CreateCommand()
cmd.CommandText = _
"INSERT INTO ppcVEKP (" & _
"ucc_exidv, " & _
"trackno_signi, " & _
"factory_lifnr, " & _
"ffs_scnnr_id, " & _
"carton_venum, " & _
"ffs_crtn_size, " & _
"ffs_scanned_pack_fl, " & _
"ffs_chng_dttm " & _
") " & _
"VALUES " & _
"(?,?,?,?,?,?,?,?)"
With Rows(i)
cmd.Parameters.Add("ucc_exidv", .Item("EXIDV"))
cmd.Parameters.Add("trackno_signi", .Item("SIGNI"))
cmd.Parameters.Add("factory_lifnr", .Item("LIFNR"))
cmd.Parameters.Add("ffs_scnnr_id", .Item("FFS_SCNNR_ID"))
cmd.Parameters.Add("carton_venum", .Item("VENUM"))
cmd.Parameters.Add("ffs_crtn_size", .Item("FFS_CRTN_SIZE"))
cmd.Parameters.Add("ffs_scanned_pack_fl",
..Item("FFS_SCANNED_PACK_FL"))
cmd.Parameters.Add("ffs_chng_dttm", .Item("FFS_CHNG_DTTM"))
End With
'Open the connection, execute the query
Try
cmd.Prepare()
cmd.ExecuteNonQuery()
Counter += 1
Catch SqlCeEx As SqlCeException
errCounter += 1
Finally
cmd.Dispose()
End Try
Next i
rtn = True
Catch SqlCeEx As SqlCeException
errorHandlerSQLce("An error occurred - Please report this error:
modGlobal.loadVEKP", SQLceex)
Catch ex As Exception
errorHandler("An error occurred - Please report this error:
modGlobal.loadVEKP", ex)
Finally
SQLce_Disconnect()
End Try
Return rtn
End Sub