private void buttonAddToRdates_Click(object sender, EventArgs e) { string connectionString = (@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Documents and Settings\nic-15\My Documents\ALRS.mdb"); OleDbConnection con = new OleDbConnection(connectionString); con.Open(); OleDbCommand cmd1 = new OleDbCommand("select renewal_dates from arms_records where thana='" + comboBoxthana.Text + "' and licence_number='" + textBoxLicence_number.Text + "'", con); OleDbDataAdapter da = new OleDbDataAdapter(cmd1); DataSet ds = new DataSet(); da.Fill(ds); int i = ds.Tables[0].Rows.Count; if (i == 1) { DialogResult result = MessageBox.Show("Previous Renewal Dates:"+cmd1.ExecuteScalar().ToString()+"\n Do you want to add: "+dateTimePickerRenewDate.Value.ToShortDateString()+" to renewal dates?", "Date will be added to Renewal dates.!!!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { //code for yes ds.Clear(); string query = "update arms_records set renewal_dates='" + dateTimePickerRenewDate.Value.ToShortDateString() + "'&',' & renewal_dates where thana='" + comboBoxthana.Text + "' and licence_number='" + textBoxLicence_number.Text + "'"; OleDbCommand cmd = new OleDbCommand(query, con); cmd.ExecuteNonQuery(); con.Close(); MessageBox.Show("Date added to Renewal Dates.\nPlease do enter next renewal data before updating record."); } } else { MessageBox.Show("No record found."); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)