LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

cvi sql toolkit

Solved!
Go to solution

Hi

we are using CVI 2012 and the latest sql toolkit. We want to find and update data in a mysql database. But we have the problem that we always get an error message.

 

Here is our code:

 

    // -----------------------------------------------------------------------

    // initialisiert das SQL-Toolkit
    DBInit(DB_INIT_MULTITHREADED);
    DBInit(DB_INIT_SINGLETHREADED);

    //
    sprintf(String, "DSN=SYSTEM_DATABASE; Server=127.0.0.1; Database=backup_demo8; UID=root; PWD=admin");

    //
    hdbc = DBConnect(String);

    //
    hmap = DBBeginMap(hdbc);

    //
    rw = DBMapColumnToInt (hmap, "speed", &iSpeed, &iSpeedState);
    rw = DBMapColumnToChar(hmap, "datetime", 32, cDateTime, &cDateTimeStat, "");

    // Activate the map
    hstmt = DBActivateMap(hmap, "plots");

    // Find the record we want to update
    while((rw = DBFetchNext(hstmt)) == DB_SUCCESS)
        {
        //
        if(StrICmpWithoutSurrWhiteSpace(cDateTime, "05:37") == 0)
        break;
        }

    //
    iSpeed = 10;

    // Insert the record into the database
    rw = DBPutRecord(hstmt);

    //
    rw = DBDeactivateMap(hmap);

    //
    rw = DBDisconnect(hdbc);

    // -----------------------------------------------------------------------

When we call the DBPutRecord cmd we get the attached error message

 

Does anyone can help us?

 

thanks in advance

 

best regards

Oliver

0 Kudos
Message 1 of 2
(3,239 Views)
Solution
Accepted by topic author OZI

Hi,

I found a solution meanwhile:

 

The map functions seem to be the problem.In a google research I found some remarks about similar problems.

 

By using the "normal" Activate SQL functions it is running.

 

Here is my solution:

 

    // -----------------------------------------------------------------------

    // initialisiert das SQL-Toolkit
    DBInit(DB_INIT_MULTITHREADED);
    DBInit(DB_INIT_SINGLETHREADED);

    //
    sprintf(String, "DSN=SYSTEM_DATABASE; Server=127.0.0.1; Database=database_l01; UID=root; PWD=admin");

    //
    hdbc = DBConnect(String);

    //
    hsql = DBActivateSQL(hdbc, "SELECT * FROM `data_l01`");

    //
    rw = DBBindColChar(hsql, SQL_TIME, 32, cTime, &cTimeStat, "");
    rw = DBBindColInt (hsql, SQL_SPEED, &iSpeed, &iSpeedState);

    // Find the record we want to update
    while((rw = DBFetchNext(hsql)) == DB_SUCCESS)
        {
        //
        if(StrICmpWithoutSurrWhiteSpace(cTime, "05:34") == 0)
        break;
        }

    //
    iSpeed = 15;

    // Insert the record into the database
    rw = DBPutRecord(hsql);

    //
    rw = DBDeactivateSQL(hsql);

    //
    rw = DBDisconnect(hdbc);

    // -----------------------------------------------------------------------

 

Thanks and kudos to me 😄

 

Oliver

Message 2 of 2
(3,230 Views)