Cast from type 'DBNull' to type 'String' is not valid

 Hi all,

Sorry to be posting here on what is probably a common enough error but I am at my wits end with this one. Quite simply I call an Update stored procedure in my code, passing in a number of paramaters. However, when I try to run the code, the following exception is thrown:

Cast from type 'DBNull' to type 'String' is not valid

I'm really not sure what the problem is here. I have tried hardcoding values for the string values with no success also, as well as using the IsNothing function, but no joy there either

I would really appreciate someones help as I spent 2 hours this evening trying to figure it out and it has my heart broken.

Thanks


Method going to business layer class

 

dp.UpdateEmploymentDetails(dr("END_DT"), IsNothing(Trim(dr("TIMESHEETTO"))), Trim(dr("R6")), Trim(dr("R1")), Trim(dr("SPLITTEAM3")), Trim(dr("SPLITTEAM2")), Trim(dr("SPLITTEAM1")), Trim(dr("AJ_SPLITPERCENTAGE3")), Trim(dr("AJ_SPLITPERCENTAGE2")), Trim(dr("AJ_SPLITPERCENTAGE1")), Trim(dr("AJ_SPLITCON3")), Trim(dr("AJ_SPLITCON2")), Trim(dr("AJ_SPLITCONT1")), Trim(dr("AJ_SAGECODE")), Trim(dr("REPORT_TO")), Trim(dr("RATETYPE")), Trim(dr("AJ_PURCHASEORDER")), Trim(dr("R10")), Trim(dr("R5")), Trim(dr("PERSON")), Trim(dr("PACCNO")), Trim(dr("R8")), Trim(dr("R3")), Trim(dr("R7")), Trim(dr("R2")), Trim(dr("ONLINEAPPROVER")), Trim(dr("NOMINAL2")), Trim(dr("NOMINAL")), Trim(dr("JOB_TITLE")), Trim(dr("JOBREF")), Trim(dr("JOBHISTORYUNIQUEID")), Trim(dr("HOLSINCLUDED")), Trim(dr("HOLHRSTAKEN")), Trim(dr("R9")), Trim(dr("R4")), Trim(dr("AJ_HISTREF")), dr("STARTDT"), Trim(dr("DIVISION")), Trim(dr("DEPT_CODE")), Trim(dr("AJ_CONTRACTTYPE")), Trim(dr("AJ_CONSULTANT")), Trim(dr("COMPANY")), Trim(dr("BACKUPAPPROVER")), dr("ADAPTORIGIN"), Trim(dr("ACTUALJOBREF")), Trim(dr("ACCUMULATEDHRS")), dr("DAYINHOURS"), dr("ALLOWOT"), Trim(dr("HOLHRSREMAINING")))

 


Business layer class method calling stored procedure:

 

 Public Shared Sub UpdateEmploymentDetails(ByVal p_TODATE As Date, ByVal p_TIMESHEETTO As String, ByVal p_STDERRATE As String, ByVal p_STDEERATE As String, ByVal p_SPLITTEAM3 As String, ByVal p_SPLITTEAM2 As String, ByVal p_SPLITTEAM1 As String, ByVal p_SPLITPERCENTAGE3 As String, ByVal p_SPLITPERCENTAGE2 As String, ByVal p_SPLITPERCENTAGE1 As String, ByVal p_SPLITCON3 As String, ByVal p_SPLITCON2 As String, ByVal p_SPLITCON1 As String, ByVal p_SAGECODE As String, ByVal p_REPORTTO As String, ByVal p_RATETYPE As String, ByVal p_PURCHASEORDER As String, ByVal p_PHOLERRATE As String, ByVal p_PHOLEERATE As String, ByVal p_PERSON As String, ByVal p_PACCNO As String, ByVal p_OT2ERRATE As String, ByVal p_OT2EERATE As String, ByVal p_OT1ERRATE As String, ByVal p_OT1EERATE As String, ByVal p_ONLINEAPPROVER As String, ByVal p_NOMINAL2 As String, ByVal p_NOMINAL As String, ByVal p_JOBTITLE As String, ByVal p_JOBREF As String, ByVal p_JOBHISTORYUNIQUEID As String, ByVal p_HOLSINCLUDED As String, ByVal p_HOLHRSTAKEN As String, ByVal p_HOLERRATE As String, ByVal p_HOLEERATE As String, ByVal p_HISTREF As String, ByVal p_FROMDATE As Date, ByVal p_DIVISION As String, ByVal p_DEPARTMENT As String, ByVal p_CONTRACTTYPE As String, ByVal p_CONSULTANT As String, ByVal p_COMPANY As String, ByVal p_BACKUPAPPROVER As String, ByVal p_ADAPTORIGIN As Integer, ByVal p_ACTUALJOBREF As String, ByVal p_ACCUMULATEDHOURS As String, ByVal p_DAYINHOURS As Double, ByVal p_ALLOWOT As Integer, ByVal p_HOLHRSREMAINING As String)
        Dim conn As String = ConfigurationSettings.AppSettings("ITTESOracleServer")
        oracleHelper.ExecuteNonQuery(conn, "Tes.ADM_UPDATE_EMPLOYMENTDETAILS ", p_TODATE, p_TIMESHEETTO, p_STDERRATE, p_STDEERATE, p_SPLITTEAM3, p_SPLITTEAM2, p_SPLITTEAM1, p_SPLITPERCENTAGE3, p_SPLITPERCENTAGE2, p_SPLITPERCENTAGE1, p_SPLITCON3, p_SPLITCON2, p_SPLITCON1, p_SAGECODE, p_REPORTTO, p_RATETYPE, p_PURCHASEORDER, p_PHOLERRATE, p_PHOLEERATE, p_PERSON, p_PACCNO, p_OT2ERRATE, p_OT2EERATE, p_OT1ERRATE, p_OT1EERATE, p_ONLINEAPPROVER, p_NOMINAL2, p_NOMINAL, p_JOBTITLE, p_JOBREF, p_JOBHISTORYUNIQUEID, p_HOLSINCLUDED, p_HOLHRSTAKEN, p_HOLERRATE, p_HOLEERATE, p_HISTREF, p_FROMDATE, p_DIVISION, p_DEPARTMENT, p_CONTRACTTYPE, p_CONSULTANT, p_COMPANY, p_BACKUPAPPROVER, p_ADAPTORIGIN, p_ACTUALJOBREF, p_ACCUMULATEDHOURS, p_DAYINHOURS, p_ALLOWOT, p_HOLHRSREMAINING)
 End Sub

 


Stored Procedure Paramaters:

 
p_TODATE  DATE,
p_TIMESHEETTO VARCHAR2,    
p_STDERRATE VARCHAR2,  
p_STDEERATE VARCHAR2,    
p_SPLITTEAM3 VARCHAR2,     
p_SPLITTEAM2 VARCHAR2,    
p_SPLITTEAM1 VARCHAR2,     
p_SPLITPERCENTAGE3 VARCHAR2,     
p_SPLITPERCENTAGE2 VARCHAR2,    
p_SPLITPERCENTAGE1 VARCHAR2,     
p_SPLITCON3 VARCHAR2,     
p_SPLITCON2 VARCHAR2,    
p_SPLITCON1 VARCHAR2,    
p_SAGECODE VARCHAR2,    
p_REPORTTO VARCHAR2,
p_RATETYPE VARCHAR2,    
p_PURCHASEORDER VARCHAR2,    
p_PHOLERRATE VARCHAR2,    
p_PHOLEERATE VARCHAR2,    
p_PERSON VARCHAR2,
p_PACCNO VARCHAR2,    
p_OT2ERRATE VARCHAR2,     
p_OT2EERATE VARCHAR2,     
p_OT1ERRATE VARCHAR2,    
p_OT1EERATE VARCHAR2,     
p_ONLINEAPPROVER VARCHAR2,     
p_NOMINAL2 VARCHAR2,     
p_NOMINAL VARCHAR2,     
p_JOBTITLE VARCHAR2,     
p_JOBREF VARCHAR2,     
p_JOBHISTORYUNIQUEID VARCHAR2,     
p_HOLSINCLUDED VARCHAR2,     
p_HOLHRSTAKEN VARCHAR2,     
p_HOLERRATE VARCHAR2,     
p_HOLEERATE VARCHAR2,    
p_HISTREF VARCHAR2,    
p_FROMDATE DATE,     
p_DIVISION VARCHAR2,    
p_DEPARTMENT VARCHAR2,     
p_CONTRACTTYPE VARCHAR2,     
p_CONSULTANT VARCHAR2,     
p_COMPANY VARCHAR2,    
p_BACKUPAPPROVER VARCHAR2,    
p_ADAPTORIGIN INTEGER,
p_ACTUALJOBREF VARCHAR2,   
p_ACCUMULATEDHOURS VARCHAR2,
p_DAYINHOURS INTEGER,
p_ALLOWOT INTEGER,
p_HOLHRSREMAINING VARCHAR2
 


0
TommyTank2008
11/12/2008 10:42:34 PM
asp.net.web-forms 93655 articles. 5 followers. Follow

2 Replies
585 Views

Similar Articles

[PageSpeed] 12

I think one of the parms that you want to pass in to the method is DBNull, because if a value is DBNull it can not be converted to a string value, so you have to check all values first if the aren't DBNull.


Please remember to click “Mark as Answer” so I know if my answer was good enough for you. Thanks.
0
Erwin21
11/12/2008 10:54:43 PM

Hi,

'Press F9 over the following line, in order to break the program execution... and read the value of each variable... some var must be nothing.

       oracleHelper.ExecuteNonQuery(conn, "Tes.ADM_UPDATE_EMPLOYMENTDETAILS ", p_TODATE, p_TIMESHEETTO, p_STDERRATE, p_STDEERATE, p_SPLITTEAM3, p_SPLITTEAM2

Regards,


Segundo Serrano P.
Ing. Sistemas
http://www.4workgroup.com/
Blog: http://dotnet-peru.blogspot.com
0
Segundo
11/12/2008 11:45:55 PM
Reply:

Web resources about - Cast from type 'DBNull' to type 'String' is not valid - asp.net.web-forms

Resources last updated: 1/3/2016 12:14:50 PM