今天是个好日子,
截至目前我坚持这个错误
Error Converting data type 'Numeric' to Decimal
这是我的代码
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
ADDitemRecon(User,AddReconItem) 里面的代码是这样的
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();
}
我的 ItemWeight 属性是
private decimal itemWeight;
public decimal ItemWeight
{
get { return itemWeight; }
set { itemWeight = value; }
}
我敢打赌,错误出在项目重量中,因为当我输入项目重量 12345.12 时它可以正常工作,但是当我输入 1234 而不是将其视为 1234.00 时,它会将其视为 1234 仅使其成为数字..
有什么帮助吗?我不知道我的转换是否错误
顺便说一句,我在数据库中的字段是
fld_ItemWeight (decimal (38,6), not null
编辑** Decimal 中是否有任何已知错误?我现在使用 VS 2005。