SQLGetData()问题

这里我想询问一下,SQLGetData(hstmt, 1, SQL_C_SLONG, b1,20, &len_b1); 这里输出整型之后,想要判断b1或者要用b1来计算的话应该怎么做呀,我这里获取到的是一个id,然后需要做加减法,但是试了一下,错误是“不能将 "SQLCHAR *" 类型的值分配到 "int" 类型的实体”。所以应该怎么做呢?


void printweek()
{
    ret = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt);
    string str1 = "use Calendar";
    string str2 = "select time_id,week,festival from Calendar where year = ";
    string str3 = "and month =";
    string str4 = "and day_of_month =";

    string  year, month, day_of_month;

    cout << "请输入年份(1940-2040): ";
    cin >> year;
    cout << "请输入月份(01-12): ";
    cin >> month;
    cout << "请输入日: ";
    cin >> day_of_month;

    string str5 = str2 + year  + str3 + month + str4 + day_of_month ;

    ret = SQLExecDirect(hstmt, (SQLCHAR*)str1.c_str(), SQL_NTS);
    ret = SQLExecDirect(hstmt, (SQLCHAR*)str5.c_str(), SQL_NTS);
    


    if (ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO)
    {
         
        SQLCHAR b1[20], b2[20],b3[20];
        SQLLEN len_b1,len_b2, len_b3;

        while (SQLFetch(hstmt) != SQL_NO_DATA)
        {
            SQLGetData(hstmt, 1, SQL_C_SLONG, b1,20, &len_b1);
            SQLGetData(hstmt, 2, SQL_C_CHAR, b2, 20, &len_b2);
            SQLGetData(hstmt, 3, SQL_C_CHAR, b3, 20, &len_b3);

            //想在这边做计算,b1做加减法

            cout << endl;
            cout << "-----------------------"<"距离今天的天数是:"<"-----------------------"<"这天是:"<"-----------------------"<< endl;
            cout << "这天否是节日:"<"------------------------"<< endl;
            cout << endl;
            
        }
    }

    free();
}

用atoi转换成int

while (SQLFetch(hstmt) != SQL_NO_DATA)
{
    SQLGetData(hstmt, 1, SQL_C_SLONG, b1,20, &len_b1);
    SQLGetData(hstmt, 2, SQL_C_CHAR, b2, 20, &len_b2);
    SQLGetData(hstmt, 3, SQL_C_CHAR, b3, 20, &len_b3);

    int id = atoi((char*)b1);  // 转换为int类型
    int result = id + 1;  // 进行加法运算

    cout << endl;
    cout << "-----------------------"<<endl;
    cout << "距离今天的天数是:"<<result<<endl;
    cout << "-----------------------"<<endl;
    cout << "这天是:"<<b2<<endl;
    cout << "-----------------------"<< endl;
    cout << "这天否是节日:"<<b3<<endl;
    cout << "------------------------"<< endl;
    cout << endl;
}