res-> getString()使应用程序崩溃 [英] res->getString() crashes the application

查看:135
本文介绍了res-> getString()使应用程序崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

应该如何工作:用户点击带有多个ID的列表框.然后,将编辑控件与来自指定ID(行)的数据一起归档.

HOW IT SHOULD WORK: User clicks on a listbox with multitude of IDs. Then, the edit controls are filed with the data from the specified ID (row).

工作原理:它在res-> getString上崩溃

HOW IT WORKS: It crashes at 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可以工作,并且可以在程序的其他部分使用.

Digging around google I found somebody mentioning that VARCHAR type values should be fetched with getBlob. That did not help at all though, and crashed just the same. getInt works however, and is used in other parts of the program.

问题:我应该采取哪些步骤使其正常工作?

QUESTION: What steps should I take to make it work?

推荐答案

如果直接在数据库中执行同一查询,是否可以正确运行该查询?另外,所有返回的字段是否都是字符串?用名称而不是序列号来调用它们是否有效? IE. getString(1),等等.

does the same query run properly if you do it in the database directly? Also, are all the returned fields really Strings? And is it valid to call them by name, rather than by the sequence number? I.e. getString(1), etc.

这篇关于res-&gt; getString()使应用程序崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆