Actually im creating one application where i inserted user sales count, sales count is updating fine but when i edit in query by putting current date its not updating detail Here im putting whole code
Private void button1_Click_1(object sender, EventArgs e)
{
this.txtinput.MaxLength = 4;
cmd = new OleDbCommand("update Login set Sales_count= IIF(IsNull(Sales_count), 0, Sales_count) + 1 where [Unique_No]=@Unique_No and [To_Date]='#"+DateTime.Now.ToString("dd/MM/yyyy")+"#'", con);
cmd.Parameters.AddWithValue("@Unique_No", txtinput.Text);
con.Open();
int n = cmd.ExecuteNonQuery();
if (n == 0)
{
MessageBox.Show("Invalid Unique No. pls try again later");// **Debugger come to this line if i insert [To_Date]='#"+DateTime.Now.ToString("dd/MM/yyyy")+"#'** // if i remove above line in code then its updating fine
}
else
{
this.DialogResult = DialogResult.OK;
}
con.Close();
}
}
Atul RokadePosted Jul 26, 2016, 12:12 PM
Nilesh SawardekarPosted Jul 26, 2016, 12:44 AM
Nitin SontakkePosted Jul 25, 2016, 11:30 PM
You didn't mention the error.
Also consider moving db related code to a separate class, don't write db related code under the click of a button. Hugely discouragingpractice.
Atul RokadePosted Jul 25, 2016, 1:33 PM
Bhuvanesh MohankumarPosted Jul 25, 2016, 1:18 PM