{ maskedTextBox1.Mask = "00/00/0000"; maskedTextBox1.ValidatingType = typeof(System.DateTime); maskedTextBox1.TypeValidationCompleted += new TypeValidationEventHandler(maskedTextBox1_TypeValidationCompleted); toolTip1.IsBalloon = true; }
private void btn_submit_Click(object sender, EventArgs e) { string str = "insert into dates values(@discharge_date,@Discharge_Advice)"; SqlCommand cmd; cmd = new SqlCommand(str, con); cmd.Parameters.AddWithValue("@discharge_date", SqlDbType.Date).Value = Convert.ToDateTime(maskedTextBox1.Text); con.Open(); cmd.ExecuteNonQuery(); con.Close(); MessageBox.Show("Records inserted"); } private void btn_retreive_Click(object sender, EventArgs e){dtusers.Clear();SqlDataAdapter da = new SqlDataAdapter("select * from dates where discharge_date= CONVERT(smalldatetime, '" + maskedTextBox1.Text + "', 103) ", con); SqlCommandBuilder cmd = new SqlCommandBuilder(da);da.Fill(dtusers);dataGridView1.DataSource = dtusers;dataGridView1.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); }
private void btn_submit_Click(object sender, EventArgs e) { string str = "insert into dates values(@discharge_date,@Discharge_Advice)"; SqlCommand cmd; cmd = new SqlCommand(str, con); cmd.Parameters.AddWithValue("@discharge_date", SqlDbType.Date).Value = Convert.ToDateTime(maskedTextBox1.Text); con.Open(); cmd.ExecuteNonQuery(); con.Close(); MessageBox.Show("Records inserted"); }
private void btn_retreive_Click(object sender, EventArgs e){dtusers.Clear();SqlDataAdapter da = new SqlDataAdapter("select * from dates where discharge_date= CONVERT(smalldatetime, '" + maskedTextBox1.Text + "', 103) ", con); SqlCommandBuilder cmd = new SqlCommandBuilder(da);da.Fill(dtusers);dataGridView1.DataSource = dtusers;dataGridView1.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); }