数据库添加表时设置表名为中文

void Caccess_test_1Dlg::createtable()
{
    //创建表
    CString strCmd;
    strCmd.Format(_T("create table %s(** text,** text)"), "采集");
    m_pConnection->Execute(_bstr_t(strCmd), &RecordsAffected, adCmdText);

    CString strCmd2;
    strCmd2.Format(_T("create table %s(id counter PRIMARY KEY,** text,** text,** text,** image,** image,** image,** image,** image)"), "p");
    m_pConnection->Execute(_bstr_t(strCmd2), &RecordsAffected, adCmdText);
    MessageBox(L"成功建立表");

    if (m_pConnection->State)
    {
        m_pConnection->Close();
        m_pConnection = NULL;
    }
}

表名会乱码。

 

改正:

改成英文表名

或使用L

 ----End

原文地址:https://www.cnblogs.com/wxl845235800/p/7544192.html