Mysql 尝试在windows中使用ODBC从qt写入MS Sql数据库时,query exec失败

Mysql 尝试在windows中使用ODBC从qt写入MS Sql数据库时,query exec失败,mysql,sql-server,qt,Mysql,Sql Server,Qt,我用odbc连接我的MSSQL数据库并将数据写入其中。我不确定为什么会出现错误: QODBCResult::exec: unable to bind variable: “[Microsoft][ODBC SQL Server Driver]Optional feature not implemented” bool DataManager::registerClient(Client&) “INSERT INTO ClientMaster (first_name, mid_name

我用odbc连接我的MSSQL数据库并将数据写入其中。我不确定为什么会出现错误:

QODBCResult::exec: unable to bind variable: “[Microsoft][ODBC SQL Server Driver]Optional feature not implemented”

bool DataManager::registerClient(Client&)

“INSERT INTO ClientMaster (first_name, mid_name, last_name, phone_number, email_id, address_line1, address_line2, address_line3, dob) VALUES (xxx, xxx , xxx, +xxx-xxx, xx, xx, x, x, 1987-08-30)”

bool DataManager::registerClient(Client&) error “[Microsoft][ODBC SQL Server Driver]Optional feature not implemented QODBC3: Unable to bind variable”


mDatabase = QSqlDatabase::addDatabase("QODBC");
mDatabase.setDatabaseName("DRIVER={SQL SERVER};SERVER=localhost;DATABASE=GLINK_CLIENT_MGMNT;");
mDatabase.setUserName("sa");
mDatabase.setPassword("123456");

if(!mDatabase.open())
是我的数据库连接部分,下面是我的查询执行部分

        QSqlQuery query(mDatabase);

        query.prepare("INSERT INTO ClientMaster (first_name, mid_name, last_name, phone_number, "
                        "email_id, address_line1, address_line2, address_line3, dob) "
                      "VALUES (:first_name, :mid_name, :last_name, :phone_number, :email_id, "
                        ":address_line1, :address_line2, :address_line3, :dob)");

        QString phoneNumber = "+";
        phoneNumber.append(client.phoneCode);
        phoneNumber.append("-");
        phoneNumber.append(client.phoneNumber);

        query.bindValue(":first_name", client.firstName);
        query.bindValue(":mid_name", client.midName);
        query.bindValue(":last_name", client.lastName);
        query.bindValue(":phone_number", phoneNumber);
        query.bindValue(":email_id", client.emailId);
        query.bindValue(":address_line1", client.addressLine1);
        query.bindValue(":address_line2", client.addressLine2);
        query.bindValue(":address_line3", client.addressLine3);
        query.bindValue(":dob", client.dob);

        regStatus = query.exec();

问题解决了。我希望下面的案例是这个问题的具体原因

我以(
yyyy-MM-dd
)格式输入了日期,即:

我知道MSSQL只以特定的格式记录日期。我不确定这一点,但它现在运行良好

query.bindValue(":dob", client.dob.toString(yyyy-MM-dd));