private void monthCalendar1_DateChanged(object sender, DateRangeEventArgs e)
{
try
{
OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source= C:\\Users\\JAY\\Desktop\\Employee.mdb");
OleDbCommand cmd = new OleDbCommand("select * from Emp_Details WHERE DOB="+ monthCalendar1.SelectionRange.Start.ToShortDateString() +"", con);
cmd.CommandType = CommandType.Text;
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, "Emp_Details");
txtEmployeeNo.Text = ds.Tables[0].Rows[0][0].ToString();
txtName.Text = ds.Tables[0].Rows[0][1].ToString();
txtAddress.Text = ds.Tables[0].Rows[0][2].ToString();
comboBox1.Text = ds.Tables[0].Rows[0][3].ToString();
txtMobNo.Text = ds.Tables[0].Rows[0][4].ToString();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
基本上我想通过月历控件检索数据...但是当我单击月历控件的日期时出现异常,位置 0 处没有行