string connectionString = ConfigurationManager.ConnectionStrings["payroll_conn"].ConnectionString; using (SqlConnection sqlconn = new SqlConnection(connectionString)) { sqlconn.Open(); using (SqlCommand com = new SqlCommand("SELECT * FROM employee WHERE fname=@fname and designation=@designation", sqlconn)) { com.Parameters.AddWithValue("@fname", en1.Text); com.Parameters.AddWithValue("@designation", e1.Text); using (SqlDataAdapter sda = new SqlDataAdapter(com)) { ds1 = new DataSet(); sda.Fill(ds1); } try { label39.Text = ds1.Tables[0].Rows[i]["id"].ToString(); dateTimePicker1.Text = ds1.Tables[0].Rows[i]["enddate"].ToString(); } catch (Exception ex) { Console.WriteLine(ex.Message); } } }从数据库中选择后,如何向 dateTimePicker1 添加一天 我遗漏了一些东西,但我不记得了,如果我的问题不好,我该怎么办?
1 回答
精慕HU
TA贡献1845条经验 获得超8个赞
您可以解析结束日期并使用AddDays方法。
var endate = ds1.Tables[0].Rows[i]["enddate"].ToString();
var endateplus1day = DateTime.Parse(enddate).AddDays(1);
dateTimePicker1.Text = endateplus1day.ToString();
- 1 回答
- 0 关注
- 114 浏览
添加回答
举报
0/150
提交
取消