try { SqlCommand cmd = new SqlCommand("select * from buy where numero='" + comboBox1.Text + "'", con); con.Close(); con.Open(); SqlDataReader rdr = cmd.ExecuteReader(); if (rdr.Read()) { DateTime date = System.Convert.ToDateTime(dateTimePicker1.Text); date=rdr[0].ToString(); txtPrtNo.Text = rdr[1].ToString(); txtCliNo.Text = rdr[2].ToString(); txtQty.Text = rdr[3].ToString(); txtUprice.Text = rdr[4].ToString(); txtTax.Text = rdr[5].ToString(); txtTotP.Text = rdr[6].ToString(); txtBalnc.Text = rdr[7].ToString(); txtAmtpd.Text = rdr[8].ToString(); } con.Close(); } catch (Exception mn) { MessageBox.Show(mn.Message); } 解决方案 这篇关于我如何纠正此错误的代码(无法将类型'string'隐式转换为'System.DateTime')的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-13 19:37