Israel

Israel

  • NA
  • 1.3k
  • 204.1k

How to save decimal into a column

Aug 10 2016 12:04 PM
Hi!
 
I need to save number as decimal in my "amount" column. How can I do it please. I inform that the type of my column is currency.
 
See my codes:
 
conn.Open();
OleDbCommand comm = new OleDbCommand();
comm.Connection = conn;
connstr = "SELECT COUNT(*) FROM Test WHERE [Dat] = @dat";
comm.CommandText = connstr;
comm.Parameters.Clear();
comm.Parameters.AddWithValue("@dat", data.Value);
int numRecords = (int)comm.ExecuteScalar();
if (numRecords == 0)
{
//connstr = "INSERT INTO Test([dat],[amount])VALUES(@date,@amount)";
comm.CommandText = connstr;
comm.Parameters.Clear();
comm.Parameters.AddWithValue("@dat", date.Value);
comm.Parameters.AddWithValue("@amount", txtAmount.Text);
if (MessageBox.Show("Are you sure to save?", "Janela de gravação", MessageBoxButtons.YesNo) == DialogResult.Yes)
comm.ExecuteNonQuery();
}
else
{
MessageBox.Show("There no product", dtFluxoCaixa.Text);
}
conn.Close();
 

Answers (2)