OleDbCommand cmdDEPT = new OleDbCommand("SELECT INDEX, DEPT_NO, PLANLENGTH FROM tbl_Dept where DEPT_NO='"+this.DataGrid1.DataKeys[e.Item.ItemIndex].ToString()+"'", conn);这段语句有一个问题,因为DEPT_NO是int型的数据。我请问, 如果DEPT_NO是int型,这句sql语句应该怎么改? 谢谢了。
调试欢乐多
OleDbCommand cmdDEPT = new OleDbCommand( "SELECT INDEX, DEPT_NO, PLANLENGTH FROM tbl_Dept where DEPT_NO= "+Convert.ToInt32(this.DataGrid1.DataKeys[e.Item.ItemIndex].ToString())+ ,conn);
OleDbCommand cmdDEPT = new OleDbCommand( "SELECT INDEX, DEPT_NO, PLANLENGTH FROM tbl_Dept where DEPT_NO= "this.DataGrid1.DataKeys[e.Item.ItemIndex].ToString() ,conn);
楼主一定要学会自己调试
断点把变量值(SQL语句)拿出来,放在查询分析其里面--F5,看看报什么错,然后最重要的是--动脑筋