日期:2014-05-16  浏览次数:21212 次

请帮忙解决标准表达式中数据类型不匹配!
string strCon = "provider=microsoft.jet.oledb.4.0;";
  strCon += @"data source=GtestCheckPrice.mdb";
  OleDbConnection conn = new OleDbConnection();
  conn = new OleDbConnection(strCon);
  string seleSql = "select ID from zhangdan where CustomerID='" + textBox1.Text + "'";
  //OleDbDataReader dr = new OleDbDataReader();
  //OleDbDataReader dr;
  //dr.Read();
  //textBox1.Text = (string)dr["CustomerName"];

  conn.Open();
  OleDbDataAdapter da = new OleDbDataAdapter(seleSql, conn);
  DataSet ds = new DataSet();
  da.Fill(ds);
  conn.Close();
  da.Dispose();
   
  textBox2.Text = ds.Tables[0].Rows[0]["ID"].ToString();

数据库ID为自动编号类型
CustomerID为数字类型

------解决方案--------------------
调试中看下 "Update zhangdan a set a.CustomerID='" + CustomerID + "',a.DeviceName='" + DeviceName + "',a.count='" + count
+ "',a.UnitPrice=" + decimal.Parse(UnitPrice) + ",a.AllUnitPrice=" + decimal.Parse(AllUnitPrice) + ",DataTime=#" + DataTime + "# where a.ID=" + ID

看看结果是什么。学会调试程序很重要。