While inserting it shows ERROR: converting varchar to numeric ..using c#.net
CREATE TABLE [dbo].[ITEMMASTER](
[ID] [int] NULL,
[ITEMCODE] [varchar](10) NULL,
[ITEMDESCRIPTION] [varchar](50) NULL,
[BRAND] [varchar](50) NULL,
[ITEMGROUP] [varchar](50) NULL,
[ITEMUNIT] [varchar](50) NULL,
[PURCHASERATE] [numeric](12, 2) NULL,
[MANUFACTURER] [varchar](50) NULL,
[PURCHASEMRP] [numeric](12, 2) NULL,
[OPENINGQTY] [numeric](12, 2) NULL,
[OPENINGVALUE] [numeric](12, 2) NULL,
[ISACTIVE] [bit] NULL,
[REORDERLEVEL] [numeric](12, 2) NULL,
[MINSTOCKQTY] [numeric](12, 2) NULL,
[MAXSTOCKQTY] [numeric](12, 2) NULL,
[VATPERCENT] [varchar](50) NULL
) ON [PRIMARY]
if (txtItemCode.Text == "")
{
Response.Write("<script language='javascript'>alert('(*) fields are Required to Save the Data!!!');</script>");
}
else
{
Save_Record();
}
protected void Save_Record()
{
try
{
if (validate_data())
{
string strSQL;
string dbConn = ConfigurationManager.ConnectionStrings["CMC"].ConnectionString;
SqlConnection sqlConn = new SqlConnection(dbConn);
sqlConn.Open();
strSQL = "INSERT INTO [ITEMMASTER](ITEMCODE,ITEMDESCRIPTION,BRAND,ITEMGROUP,ITEMUNIT,PURCHASERATE,MANUFACTURER,PURCHASEMRP,OPENINGQTY,OPENINGVALUE,REORDERLEVEL,MINSTOCKQTY,MAXSTOCKQTY,VATPERCENT)VALUES ('" + txtItemCode.Text + "','" + txtItemDescription.Text + "','" +DDLBrand.SelectedItem.ToString() + "','" +DDLItemGroup.SelectedItem.ToString() + "','" +DDLItemUnit.SelectedItem.ToString() + "','" +txtPurchaseRate.Text + "','" +DDLMfr.SelectedItem.ToString() + "','" +txtPurchaseMRP.Text + "','" +txtOpeningQuantity.Text + "', '" +txtOpeningValue.Text + "','" +txtReorderLevel.Text + "','" +txtMinStockQty.Text + "','" +txtMaxStockQty.Text + "','" +txtVAT.Text + "' )";
//strSQL = "INSERT INTO [ITEMMASTER](ITEMCODE,ITEMDESCRIPTION,BRAND,ITEMGROUP,ITEMUNIT,PURCHASERATE,MANUFACTURER,PURCHASEMRP,OPENINGQTY,OPENINGVALUE,REORDERLEVEL,MINSTOCKQTY,MAXSTOCKQTY,VATPERCENT)VALUES ('" + txtItemCode.Text + "','" + txtItemDescription.Text + "','" +
// DDLBrand.SelectedItem.ToString() + "','" +
// DDLItemGroup.SelectedItem.ToString() + "','" +
// DDLItemUnit.SelectedItem.ToString() + "','" +
// (string.IsNullOrEmpty(txtPurchaseRate.Text) ? "0.0" : txtPurchaseRate.Text) + "','" +
// DDLMfr.SelectedItem.ToString() + "','" +
// (string.IsNullOrEmpty(txtPurchaseMRP.Text) ? "0.0" : txtPurchaseMRP.Text) + "','" +
// (string.IsNullOrEmpty(txtOpeningQuantity.Text) ? "0.0" : txtOpeningQuantity.Text) + "', '" +
// (string.IsNullOrEmpty(txtOpeningValue.Text) ? "0.0" : txtOpeningValue.Text) + "','" +
// (string.IsNullOrEmpty(txtReorderLevel.Text) ? "0.0" : txtReorderLevel.Text) + "','" +
//(string.IsNullOrEmpty(txtMinStockQty.Text) ? "0.0" : txtMinStockQty.Text) + "','" +
// (string.IsNullOrEmpty(txtMaxStockQty.Text) ? "0.0" : txtMaxStockQty.Text) + "','" +
// txtVAT.Text + "' )";
SqlCommand cmdItemMaster = new SqlCommand(strSQL, sqlConn);
cmdItemMaster.ExecuteNonQuery();
sqlConn.Close();
Response.Write("<script language='javascript'>alert('Data Saved Successfully...');</script>");
Load_Record();
Record_Count();
}
}
catch (Exception)
{
Response.Write("<script language='javascript'>alert('Error:Data Not Saved..!!!');</script>");
}
}
ABOVE IS MY TABLE AND QUERY... While inserting it shows ERROR: converting varchar to numeric .. Anyone pls help me......