【发布时间】:2014-06-03 11:31:02
【问题描述】:
它应该如何工作:用户单击具有多个 ID 的列表框。然后,使用指定 ID(行)中的数据归档编辑控件。
工作原理:它在 res->getString
处崩溃case LBN_SELCHANGE:
{
string str;
int index = SendMessage(GetDlgItem(hwnd, IDC_lbList), LB_GETCURSEL, 0, 0);
string sint = boost::lexical_cast<std::string>(index);
string smt="SELECT client, telnr, atnrem, papatn, gedapr
FROM tremreg WHERE id = ";
string query = smt + sint;
res = stmt->executeQuery(query.c_str());
//starts crashing here
str = res->getString("client");
SetDlgItemText(hwnd, IDC_eClient, str.c_str());
str = res->getString("telnr");
SetDlgItemText(hwnd, IDC_eTelNr, str.c_str());
str = res->getString("antrem");
SetDlgItemText(hwnd, IDC_eRemAtn, str.c_str());
str = res->getString("paprem");
SetDlgItemText(hwnd, IDC_ePapAtn, str.c_str());
str = res->getString("gedapr");
SetDlgItemText(hwnd, IDC_eGedApr, str.c_str());
delete res;
delete stmt;
}
break;
崩溃信息:
Unhandled exception at 0x753C812F in Registracija.exe:
Microsoft C++ exception:sql::InvalidArgumentException at memory location 0x0018F7AC.
在 google 上一探究竟,我发现有人提到应该使用 getBlob 获取 VARCHAR 类型值。但这根本没有帮助,并且同样崩溃了。但是 getInt 可以工作,并用于程序的其他部分。
问题:我应该采取哪些步骤才能使其发挥作用?
【问题讨论】:
标签: mysql winapi visual-c++ mysql-connector