数据类型不匹配,急救!!
jxqyj 2008-06-27 08:33:50 我原来是用SQL2005的,现在用ACCESS ,在SQL里功能是正常的,问题应该就是出在时间上,我是用TEXTBOX提交时间的,ACCESS表里的时间格式是 日期/时间
private void button1_Click(object sender, EventArgs e)
{
show();
}
private void show()
{
string strPath = "\\\\192.168.1.12\\共享文件\\求职名册" + "\\AAA.mdb";
string ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data source='" + strPath + "'";
OleDbConnection oleCon = new OleDbConnection(ConStr);
StringBuilder strSQL = new StringBuilder();
oleCon.Open();
DataTable dt = new DataTable("卡");
OleDbDataAdapter da = new OleDbDataAdapter(getsql(),oleCon);
da.Fill(dt);
dataGridView1.DataSource = dt.DefaultView;
oleCon.Close();
}
private string getsql()
{
string sql = "select * from 卡 where id>=0";
if (textBox4.Text != null && textBox4.Text != "" && textBox5.Text != null && textBox5.Text != "")
sql += " and indate between '" + DateTime.Parse(textBox4.Text) + "' and '" + DateTime.Parse(textBox5.Text) + "'";//应该就是这里有问题,我不知道ACCESS的时间转换是否正确
if (comboBox2.Text != null && comboBox2.Text != "")
sql += " and 卡状态='" + comboBox2.Text + "'";
return sql += "order by id desc";
}
大家帮帮我吧!