Sql Table : stocks
Colomn Name | Data Type
------------------------------
Stock_no | nvarchar(15)
Quantity | int
Gem.Weight | float
Cost | decimal(18,2)
My stock insert form code:
private void stocks_Click(object sender, EventArgs e)
{
try
{
cmd = new SqlCommand("INSERT INTO Stocks VALUES('" + txt_stock_no.Text + "', '"
+ txt_qty.Text + "','" + txt_gem_weight.Text + "', '" + txt_cost.Text + "')", conn);
MessageBox.Show("You've inserted successfully!", "Successful Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
conn.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
I think the the error should be with my '.text' has issues.. i tried making changing with it even though its not working.