this.txtinput.MaxLength = 4; string connectionString = null; connectionString = ConfigurationManager.ConnectionStrings["AccessConnectionString"].ConnectionString; con.ConnectionString = connectionString; string access = "select To_Date from Login"; cmd = new OleDbCommand(access, con); con.Open(); using (OleDbDataReader read = cmd.ExecuteReader()) { while (read.Read()) { string date2 = read["To_Date"].ToString(); if (todaydate == date2) { cmd = new OleDbCommand("update Login set Sales_count= IIF(IsNull(Sales_count), 0, Sales_count) + 1, [To_Date]=Date() where [Unique_No]=@Unique_No", con); cmd.Parameters.AddWithValue("@Unique_No", txtinput.Text); con.Open(); int n = cmd.ExecuteNonQuery(); if (n == 0) { MessageBox.Show("Invalid Unique No."); } else { this.DialogResult = DialogResult.OK; } con.Close(); } else { cmd = new OleDbCommand("IF NOT EXISTS(SELECT 1 FROM Login WHERE Unique_No = @Unique_No) INSERT INTO(Sales_count,To_Date)values(?,Date()) ", con); cmd.Parameters.AddWithValue("@Unique_No", txtinput.Text); con.Open(); int n = cmd.ExecuteNonQuery(); if (n == 0) { MessageBox.Show("Invalid Unique No."); } else { this.DialogResult = DialogResult.OK; } con.Close(); } } } con.Close();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)