显示参数不足,但是对应的数据库还有程序对应的个数都一样,找不出问题。最后运行后可以修改但是后边刷新数据库没有用,应该是sql语句有问题,有没有人会的,教教
void BEILIAO::OnBnClickedButton3()//修改
{
// TODO: 在此添加控件通知处理程序代码
CString strd1, strd2, strId, strd1s, strd1x, strd2s, strd2x;
GetDlgItemText(IDC_EDIT4, strId);
GetDlgItemText(IDC_EDIT1, strd1);
GetDlgItemText(IDC_EDIT3, strd1s);
GetDlgItemText(IDC_EDIT5, strd1x);
GetDlgItemText(IDC_EDIT2, strd2);
GetDlgItemText(IDC_EDIT6, strd2s);
GetDlgItemText(IDC_EDIT8, strd2x);
if (strId.IsEmpty()) {
MessageBox(_T("请输入要修改的编号"), _T("修改操作"), MB_ICONWARNING);
return;
}
// 2、执行 SQL语句
CString strSql = _T("update beiliao set ");
//strSql += _T("beiliao.[d1]=\'") + strd1 + _T("\'");
//strSql += _T(",beiliao.[d1s]=\'") + strd1s + _T("\'");
//strSql += _T(",beiliao.[d1x]=\'") + strd1x + _T("\'");
//strSql += _T(",beiliao.[d2]=\'") + strd2 + _T("\'");
//strSql += _T(",beiliao.[d2s]=\'") + strd2s + _T("\'");
//strSql += _T(",beiliao.[d2x]=\'") + strd2x + _T("\'");
strSql += _T("beiliao.[d1]=") + strd1;
strSql += _T(",beiliao.[d1s]=") + strd1s;
strSql += _T(",beiliao.[d1x]=") + strd1x;
strSql += _T(",beiliao.[d2]=") + strd2;
strSql += _T(",beiliao.[d2s]=") + strd2s;
strSql += _T(",beiliao.[d2x]=") + strd2x;
strSql += _T(" where beiliao.[ID]=") + strId;
MessageBox(strSql);
try {
m_db.ExecuteSQL(strSql);
}
catch (CDBException* e) {
MessageBox(_T("" + e->m_strError), _T("修改操作"), MB_ICONWARNING);
return;
}
// 3、更新列表框的显示
strSql = _T("select beiliao.[ID], beiliao.[d1], beiliao.[d1s] , beiliao.[d1x], beiliao.[strd2] , beiliao.[strd2s], beiliao.[strd2x] from beiliao order by beiliao.[ID] asc;");
DispBySql(strSql);
}