渡すNumericことで、あなたはあなたが数を渡していることをNpgsqlに保証しました。次に、文字列を渡しました。
他のコードが原因で、に10進値がtxt_priceあり、他に何も存在しない可能性があることをすでに確信している場合は、次を使用します。
autoInsert.Parameters[0].Value = decimal.Parse(txt_price.Text);
それ以外の場合は、他のことを行う前に、コードと組み合わせてこれを確認してください。
decimal price;
if(!decimal.TryParse(txt_price.Text, out price))
{
//code to display message that txt_price doesn't have a valid value.
return;
}
using(var con = /*your code that constructs the connection*/)
{
using(autoInsert = /*your code that returns to command*/)
{
autoInsert.Parameters.Add(new NpgsqlParameter("price", NpgsqlDbType.Numeric));
autoInsert.Parameters[0].Value = price;
con.Open();
autoInsert.ExecuteNonQuery();
con.Close();
}
}