.net in script component
hi,
my table field is getting value from file,if * is there, then it null.
now in my script component ,
Select Case (segmentcode.ToUpper())
Case Segments.EMP.ToString.ToUpper()
Row.empno = Convert.ToInt32(SegmentValue(arrLine, 1))
Row.empname = SegmentValue(arrLine, 2)
-- Row.salary_IsNull = Convert.ToInt32(SegmentValue(arrLine, 3))
Row.manager = SegmentValue(arrLine, 4)
if you see here ,salary is null in file,means it has *,i need to put blank in my table.
if i run this script ,i am getting error,because of third line, Row.salary_IsNull = Convert.ToInt32(SegmentValue(arrLine, 3))
how to handle this
October 31st, 2012 11:34am
So why not If
Convert.ToInt32(SegmentValue(arrLine, 3)) == "*" then Row.salary_IsNull =
""?Arthur My Blog
Free Windows Admin Tool Kit Click here and download it now
October 31st, 2012 11:49am
ok,
the thing is ,if there * in the file means its blank.
if i simply use Row.empname = SegmentValue(arrLine, 2),it place blank in the table in sql.
as empname is string in file and in sql table.
now if any field is integer and i am getting blank, it thorws me an error.
Row.salary = Convert.ToInt32(SegmentValue(arrLine, 3)),
here for salary , its blank in the file,here i am convering it into integer, so its throwing error.i cannot remove Convert.ToInt32
as sometimes in the files its integer value sometimes it is blank.
October 31st, 2012 12:54pm
The question is if the target accepts NULLs for salary.
If yes, then
Row.salary = DBNull.Value
PS:
1) Obviously before you assign you check if empty, and
2) do not forget to add a using statement to System.DBNullArthur My Blog
Free Windows Admin Tool Kit Click here and download it now
October 31st, 2012 2:08pm
i added row.salary = system.dbnull.value
it showing an error
November 1st, 2012 8:16am
Replace row.salary = system.dbnull.value with
row.salary_IsNull = True
Rajkumar
Free Windows Admin Tool Kit Click here and download it now
November 1st, 2012 8:23am