I am getting this error at runtime (Specified cast is not valid.) even when the 2 parameters are int and their values are way less than infinity.. ( they are 1002 and 25).
The return type is a nullable int (int?)
int iInspectionID =
Convert.ToInt32(this.inspectionTableAdapter.InsertInspection(dtpInspectionDate.Value.Date);
if (iInspectionID != 0) {
int iDisposition =
Convert.ToInt32(cmbInspectionResults.SelectedValue);
int? iDispositionID =
this.Inspection_DispositionsTableAdapter.InsertInspection_Disposition(iDisposition, iInspectionID); <<< --- ERROR HERE
Was the table adapter created with a wizard? Open the wizard back up and view the SQL code or the stored procedure, as the SQL is most likely where your code is bombing. You can't step into that with the debugger.
---------------------------------------
MCP - Web Based Client Development .NET 2.0
prashant0268
Member
2 Points
6 Posts
ERROR: "When casting from a number, the value must be a number less than infinity."
Sep 25, 2007 03:26 PM|LINK
I am getting this error at runtime (Specified cast is not valid.) even when the 2 parameters are int and their values are way less than infinity.. ( they are 1002 and 25).
The return type is a nullable int (int?)
int iInspectionID = Convert.ToInt32(this.inspectionTableAdapter.InsertInspection(dtpInspectionDate.Value.Date); if (iInspectionID != 0) { int iDisposition = Convert.ToInt32(cmbInspectionResults.SelectedValue); int? iDispositionID = this.Inspection_DispositionsTableAdapter.InsertInspection_Disposition(iDisposition, iInspectionID); <<< --- ERROR HEREPlease advise..
ps2goat
Star
10845 Points
1977 Posts
Re: ERROR: "When casting from a number, the value must be a number less than infinity."
Sep 25, 2007 03:48 PM|LINK
What is the definition for this.Inspection_DispositionsTableAdapter.InsertInspection_Disposition? And what parameter types does it expect?
MCP - Web Based Client Development .NET 2.0
prashant0268
Member
2 Points
6 Posts
Re: ERROR: "When casting from a number, the value must be a number less than infinity."
Sep 25, 2007 05:45 PM|LINK
public
virtual System.Nullable<int> InsertInspection_Disposition(int DispositionTypeID, int InspectionID) {jguadagno
Contributor
3823 Points
587 Posts
Re: ERROR: "When casting from a number, the value must be a number less than infinity."
Sep 25, 2007 05:48 PM|LINK
Did you step in to the InsertInspection_Dispisution method. I suspect the error is happening there.
My Website: http://www.josephguadagno.net
hemantpurkar
Member
276 Points
65 Posts
Re: ERROR: "When casting from a number, the value must be a number less than infinity."
Sep 25, 2007 05:59 PM|LINK
Try using as below:
int iDispositionID this.Inspection_DispositionsTableAdapter.InsertInspection_Disposition(iDisposition, iInspectionID) ?? default(int);
( Principal Software Consultant )
-------------------------------------------------
Please mark it as answer if it helps you resolve
hemantpurkar
Member
276 Points
65 Posts
Re: ERROR: "When casting from a number, the value must be a number less than infinity."
Sep 25, 2007 06:00 PM|LINK
Sorry for syntax error on above post, I mean as below:
Try using as below:
int iDispositionID = this.Inspection_DispositionsTableAdapter.InsertInspection_Disposition(iDisposition, iInspectionID) ?? default(int);
( Principal Software Consultant )
-------------------------------------------------
Please mark it as answer if it helps you resolve
prashant0268
Member
2 Points
6 Posts
Re: ERROR: "When casting from a number, the value must be a number less than infinity."
Sep 25, 2007 06:03 PM|LINK
Hemant, I tried using the solution but it is still not working..
hemantpurkar
Member
276 Points
65 Posts
Re: ERROR: "When casting from a number, the value must be a number less than infinity."
Sep 25, 2007 06:07 PM|LINK
I hope, you web site is pointing to framework 2.0 in IIS as Nullable Types are introduced in 2.0 :)
( Principal Software Consultant )
-------------------------------------------------
Please mark it as answer if it helps you resolve
prashant0268
Member
2 Points
6 Posts
Re: ERROR: "When casting from a number, the value must be a number less than infinity."
Sep 25, 2007 06:07 PM|LINK
The error is happening at that location and it is occuring before I can step into that procedure.
ps2goat
Star
10845 Points
1977 Posts
Re: ERROR: "When casting from a number, the value must be a number less than infinity."
Sep 25, 2007 06:38 PM|LINK
Was the table adapter created with a wizard? Open the wizard back up and view the SQL code or the stored procedure, as the SQL is most likely where your code is bombing. You can't step into that with the debugger.
MCP - Web Based Client Development .NET 2.0