'DBNull' to type 'Integer' is not valid

1,288 views
Skip to first unread message

Sheila Christopher

unread,
Jan 11, 2012, 1:35:35 PM1/11/12
to ArcSWAT, SWAT-user
I wondered if you could help me.  I am getting an error (see below) when I re-write my sol table.  I had zeros for a few bulk densities (in open water,WATR).   When I filled in bulk density values and tried to re-write my table, the same error came up.  I have zeros for other variables like sol_awc. I wonder if there can be no zeros in the sol table?  Or is the error from something other than having zeros in my table?

Thanks, Sheila

Here is the error:

Unhandled exception has occurred in a component in your application.  If you click Continue, the application will ignore this error and attempt to continue.

Conversion from 'DBNull' to type 'Integer' is not valid

See the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.InvalidCastException: Conversion from type 'DBNull' to type 'Integer' is not valid.
   at Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(Object Value)
   at SWAT_InputFileEdit.mPrintInputFiles2005.PrintSolFile(DataTable pSolTab)
   at SWAT_InputFileEdit.frmWriteInputFiles.cmdOK_Click(Object sender, EventArgs e)
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies ************** mscorlib
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5448 (Win7SP1GDR.050727-5400)
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
SWAT_HRUs
    Assembly Version: 0.0.0.0
    Win32 Version: 0.0.0.0
    CodeBase: file:///C:/Swat/ArcSWAT/SWAT_HRUs.dll
----------------------------------------
ESRI.ArcGIS.System
    Assembly Version: 9.3.0.1770
    Win32 Version: 9.3.0.1770
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/ESRI.ArcGIS.System/9.3.0.1770__8fc3cc631e44ad86/ESRI.ArcGIS.System.dll
----------------------------------------
SWAT_WD
    Assembly Version: 1.1.4268.10990
    Win32 Version: 1.1.4268.10990
    CodeBase: file:///C:/Swat/ArcSWAT/SWAT_WD.dll
----------------------------------------
SWAT_PM2
    Assembly Version: 1.0.4268.10990
    Win32 Version: 1.0.4268.10990
    CodeBase: file:///C:/Swat/ArcSWAT/SWAT_PM2.dll
----------------------------------------
Microsoft.VisualBasic
    Assembly Version: 8.0.0.0
    Win32 Version: 8.0.50727.5420 (Win7SP1.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------
System
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5447 (Win7SP1GDR.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
ESRI.ArcGIS.ArcMapUI
    Assembly Version: 9.3.0.1770
    Win32 Version: 9.3.0.1770
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/ESRI.ArcGIS.ArcMapUI/9.3.0.1770__8fc3cc631e44ad86/ESRI.ArcGIS.ArcMapUI.dll
----------------------------------------
Interop.Scripting
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///C:/Swat/ArcSWAT/Interop.Scripting.DLL
----------------------------------------
System.Windows.Forms
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5446 (Win7SP1GDR.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
ESRI.ArcGIS.Framework
    Assembly Version: 9.3.0.1770
    Win32 Version: 9.3.0.1770
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/ESRI.ArcGIS.Framework/9.3.0.1770__8fc3cc631e44ad86/ESRI.ArcGIS.Framework.dll
----------------------------------------
System.Web
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5456 (Win7SP1GDR.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_32/System.Web/2.0.0.0__b03f5f7f11d50a3a/System.Web.dll
----------------------------------------
System.Data
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
System.Xml
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Transactions
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
    CodeBase: file:///C:/Windows/assembly/GAC_32/System.Transactions/2.0.0.0__b77a5c561934e089/System.Transactions.dll
----------------------------------------
System.EnterpriseServices
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_32/System.EnterpriseServices/2.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll
----------------------------------------
System.Configuration
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
ESRI.ArcGIS.SystemUI
    Assembly Version: 9.3.0.1770
    Win32 Version: 9.3.0.1770
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/ESRI.ArcGIS.SystemUI/9.3.0.1770__8fc3cc631e44ad86/ESRI.ArcGIS.SystemUI.dll
----------------------------------------
SWAT_InputFileGen
    Assembly Version: 1.0.4268.10990
    Win32 Version: 1.0.4268.10990
    CodeBase: file:///C:/Swat/ArcSWAT/SWAT_InputFileGen.dll
----------------------------------------
SWAT_InputFileEdit
    Assembly Version: 1.0.4268.10990
    Win32 Version: 1.0.4268.10990
    CodeBase: file:///C:/Swat/ArcSWAT/SWAT_InputFileEdit.dll
----------------------------------------
SWAT_RunSwat
    Assembly Version: 1.0.4268.10990
    Win32 Version: 1.0.4268.10990
    CodeBase: file:///C:/Swat/ArcSWAT/SWAT_RunSwat.dll
----------------------------------------
ESRI.ArcGIS.Geodatabase
    Assembly Version: 9.3.0.1770
    Win32 Version: 9.3.0.1770
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/ESRI.ArcGIS.Geodatabase/9.3.0.1770__8fc3cc631e44ad86/ESRI.ArcGIS.Geodatabase.dll
----------------------------------------
ESRI.ArcGIS.DataSourcesGDB
    Assembly Version: 9.3.0.1770
    Win32 Version: 9.3.0.1770
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/ESRI.ArcGIS.DataSourcesGDB/9.3.0.1770__8fc3cc631e44ad86/ESRI.ArcGIS.DataSourcesGDB.dll
----------------------------------------
CustomMarshalers
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_32/CustomMarshalers/2.0.0.0__b03f5f7f11d50a3a/CustomMarshalers.dll
----------------------------------------

************** JIT Debugging ************** To enable just-in-time (JIT) debugging, the .config file for this application or computer (machine.config) must have the jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging enabled.

For example:

<configuration>
    <system.windows.forms jitDebugging="true" /> </configuration>

When JIT debugging is enabled, any unhandled exception will be sent to the JIT debugger registered on the computer rather than be handled by this dialog box.

Jim Almendinger

unread,
Jan 11, 2012, 2:57:05 PM1/11/12
to Sheila Christopher, ArcSWAT, SWAT-user
I'm not much of a database / programmer type, but it looks like you may have blank values (nulls), and not just zeroes, in your data set.  That would be a problem.  Or, if you're missing a column of data, the program may be trying to read beyond the end of a line and finding nothing.  
But -- I'm really guessing here.  
-- Jim

--
You received this message because you are subscribed to the Google Groups "ArcSWAT" group.
To post to this group, send email to arc...@googlegroups.com.
To unsubscribe from this group, send email to arcswat+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/arcswat?hl=en.

Dr. James E. Almendinger, Senior Scientist
St. Croix Watershed Research Station
Science Museum of Minnesota
16910  152nd St. N
Marine on St. Croix, MN  55047
tel: 651-433-5953 X 19
fax: 651-433-5924
email: din...@smm.org
web: www.smm.org/SCWRS/




Jochen

unread,
Aug 27, 2013, 11:40:16 AM8/27/13
to arc...@googlegroups.com, SWAT-user
I also can confirm that blanks lead to this error message

Cva Shrestha

unread,
Apr 27, 2017, 6:02:38 AM4/27/17
to ArcSWAT, swat...@googlegroups.com
when do you face unit conversion error in pcp1.pcp files.


i have checked the pcp files ,
no blank..no non numeric item...no items above 999.9
1kil.JPG

Shaffiq Somani

unread,
May 31, 2017, 11:22:04 AM5/31/17
to SWAT-user, arc...@googlegroups.com
I have the same issue in the building of the  management 2 table.  I would think that the management 2 file would be automatically generated and would not have that issue.  See screenshot.  Does anyone have any idea on where to potentially look.

Thanks,  

Shaffiq
SWAT Error.PNG
Reply all
Reply to author
Forward
0 new messages