Good Day Everyone,
As of now im stuck with this error
Error Converting data type 'Numeric' to Decimal
this is my code
AddManualItems AddReconItem = new AddManualItems();
UserAccess user = new UserAccess();
AddReconItem.BranchCode = BranchCodeTextBox.Text;
AddReconItem.ForLoanMonth = YearDropDownList.SelectedValue + "/" + MonthDropDownList.SelectedValue;
AddReconItem.ItemWeight = Convert.ToDecimal(WeightTextBox.Text);
AddReconItem.PrincipalAmount = Convert.ToDecimal(PrincipalTexAmTextBox.Text);
AddReconItem.PawnTicket = PwnTicketTextBox.Text;
AddReconItem.ItemStorageGroup = Convert.ToInt16(StorageNameDropDownList.SelectedValue);
AddReconItem.ReconID = Convert.ToInt16(ReconTypeDropDownList.SelectedValue);
user.UserID = Session["UserID"].ToString();
string a = servs.AddItemRecon(user, AddReconItem); // this is where the error appears in debug mode
the code inside of the ADDitemRecon(User,AddReconItem) is this
using (SqlConnection reportsConn = new SqlConnection(sqlConnWriter))
{
reportsConn.Open();
SqlCommand AddReconItem = new SqlCommand();
AddReconItem.Connection = reportsConn;
AddReconItem.CommandType = CommandType.StoredProcedure;
AddReconItem.CommandText = "Updater.usp_AddReconcileItems";
AddReconItem.Parameters.AddWithValue("@ITEMWEIGHT", Convert.ToDecimal( items.ItemWeight));
AddReconItem.Parameters.AddWithValue("@ITEMPRINCIPALAMT", Convert.ToDecimal(items.PrincipalAmount));
AddReconItem.Parameters.AddWithValue("@FORLOANMONTH", Convert.ToDateTime(items.ForLoanMonth));
AddReconItem.Parameters.AddWithValue("@STORAGEGROUPID", items.ItemStorageGroup);
AddReconItem.Parameters.AddWithValue("@BRANCHCODE", items.BranchCode);
AddReconItem.Parameters.AddWithValue("RECONID", items.ReconID);
AddReconItem.Parameters.AddWithValue("@PAWNTIX",items.PawnTicket);
AddReconItem.Parameters.AddWithValue("@CREATEDBY", user.UserID.ToString());
AddReconItem.ExecuteNonQuery();
}
my property for ItemWeight is
private decimal itemWeight;
public decimal ItemWeight
{
get { return itemWeight; }
set { itemWeight = value; }
}
i bet the error is in the item weight because when i input in the item weight 12345.12 it works fine, but when i input 1234 instead of treating it as 1234.00 it treats it as 1234 only making it numeric..
any help? i do not know if my conversions are wrong
By the way my field in database is
fld_ItemWeight (decimal (38,6), not null
EDIT** Is there any bugs known in Decimal?? im using VS 2005 as of now.
Found The answer! my stored Procedure is wrong i have decimal(9,6) in my stored procedured making it accept 3 digits or less !changed it to (18,2)\
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With