Cvi sql toolkit

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
Solved!
Go to Solution.
Attachments:
Errormessage.JPG ‏50 KB

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 :-D
Oliver

Similar Messages

  • How can I transfer a XML file content to a MS SQL database by stored procedure using LabWindows/CVI SQL Toolkit?

    Hi,
    I have a problem to transfer a XML file content to a MS SQL database by a given/fixed stored procedure. I'm able to transfer the content of the file by using following method ...
    hstmt = DBPrepareSQL (hdbc, EXEC usp_InsertReport '<Report> ..... </Report>');
    resCode = DBExecutePreparedSQL (hstmt);
    resCode = DBClosePreparedSQL (hstmt);
    ... but in this case I'm not able to fetch the return value of the stored procedure! 
    I have tried to follow the example of the stored procedure in the help documentation (DBPrepareSQL) but I miss a datatype for xml?!?
    Any idea how to solve my problem?
    KR Cake  
    Solved!
    Go to Solution.

    After some additional trials I found a solution by calling the stored procedure in this way
    DBSetAttributeDefault (hdbc, ATTR_DB_COMMAND_TYPE, DB_COMMAND_STORED_PROC);
    DBPrepareSQL (hdbc, "usp_InsertReport");
    DBCreateParamInt (hstmt, "", DB_PARAM_RETURN_VALUE, -1);
    DBCreateParamChar (hstmt, "XMLCONTENT", DB_PARAM_INPUT, sz_Buffer, (int) strlen(sz_Buffer) + 1 );
    DBExecutePreparedSQL (hstmt);
    DBClosePreparedSQL (hstmt);
    DBGetParamInt (hstmt, 1, &s32_TestId);
    where sz_Buffer is my xml file content and s32_TestID the return value of the stored procdure (usp_InsertReport(@XMLCONTENT XML))
    Now I face the problem, that DBCreateParamChar limits the buffer size to 8000 Bytes.
    Any idea to by-pass this shortage??

  • Is SQL Connection Function or API Availble in SQL Toolkit 2.2 (Urgent) ?

    Hello,
    I have build an application using LabWindows 2010 and SQL Toolkit 2.2. Is there any function or dll or api availble so that i do not want to make connection in control panel ODBC ?.
    Regards
    Umer
    Solved!
    Go to Solution.

    Hello,
    The manual for this toolkit might be a good reference for you: LabWindows/CVI SQL Toolkit Help
    There is a function called DBConnect, which allows you to connect to a database programmatically. The Help says:
    "Purpose: Opens a to a database system to allow execution of SQL statements. Calling DBConnect is equivalent to calling DBNewConnection and then DBOpenConnection"
    There's also a page in the help titled Connecting to a Database, which tells you more information about how to use DBConnect:
    "Use DBConnect to connect to a data source. The only parameter is a connection string, which must contain the data source or provider name and any other attributes the database requires. DBConnect returns a handle to the database connection that other functions in the toolkit use. Call DBDisconnect to close the database connection, passing in the database connection handle from DBConnect. The following code is a simplified version of the code found in connect.prj.
    int hdbc = 0; /* Handle to database connection. */
    int rescode; /*Result code. */
    /* Connect to CVI_Samples data source. */
    hdbc = DBConnect ("DSN=CVI Samples");
    if (hdbc <= 0) goto Error;
    /* Disconnect from database. */
    resCode = DBDisconnect (hdbc);
    if (resCode != DB_SUCCESS) goto Error;"
    Hope this helps.
    Taylor B.
    National Instruments

  • SQL toolkit

    I've added sqldistsupp.dsn and sqldistsupp.exe in my distribution kit to configure a database's connection automatically.
    In order to get connection to SQL Server instead MS Access what changes in the sqldistsupp.dsn I have to do?
    Thanks

    Hello YG,
    I have not been able to find an example for this, but you may want to check out the LabWindows CVI SQL Toolkit Reference Manual.  Chapter 2 has more useful info on the database connections that are possible.
    Regards,
    Shawn S. | NIC
    Instrument Driver/IVI PSE
    National Instruments

  • How to compact and repair a MS Access database with NI CVI 8.5 (and SQL Toolkit)

    Hello
    I'm using the SQL Toolkit with CVI 8.5 for accessing MS Access Databases.
    Is there a possibility to compact and repair the .mdb file with  CVI?
    Thanks in advance.

    Hello Ulrich,
    with compact and repair I mean the MSAccess function "Compact and Repair".
    Please follow the link below for more details:
    http://office.microsoft.com/en-us/access-help/compact-and-repair-an-access-file-HP005187449.aspx
    Normally you can execute this function directly in Access or with the Windows ODBC Data Sources Administrator  => "Control Panel" => "Administrative Tools" => "Data Sources (ODBC)"...
     I want to execute this function via cvi code and not by hand ;-).
    Thank you for your support.
    Frank

  • LabWindows CVI and SQL Toolkit cursor/sch​ema error

    We are using CVI 8.5 and SQL Toolkit 2.0.6 to write data to a SQL Server 2008 database.  We are utilizing the Microsoft ODBC SQL Server (non-native) driver.  We build a transaction that calls stored procedures on the database to write the data.  Occasionally we get the following error:
    "Could not complete cursor operation because the table schema changed after the cursor was declared"
    The error is unusual since we only use one cursor and it is in a stored procedure that gets called by other software hundreds of times a day and never fails.  Our database is also designed to only append records, not change existing ones.  We're trying to pinpoint the error and I'm wondering if anyone knows if the SQL Toolkit uses cursors to build transactions or if this error has been seen by others.  Since upgrading the toolkit or drivers takes a lot of effort, I want to make sure that I understand the problem before I start throwing darts at it.  Thanks in advance for any insight.

    I've attached the function that's failing.  Unfortunately, the code isn't designed with much resolution as to what SQL toolkit call failed, since these calls haven't failed once validated and put into the production environment.  Can you tell if any of these functions use a cursor.  I could certainly try adding more resolution to the error handling, but since we've only seen errors occasionally in the production environment, I'd need to release a temp version and monitor it.  Let me know what you think.  Thanks.
    Attachments:
    StoreTestData.txt ‏5 KB

  • I want to install Distribution kit Created in cvi 5.5 with sql toolkit 2

    I want to install Distribution kit with CVI runtime created in CVI5.5 using sql toolkit 2. While installing Distribution in new PC the sql error is showing and it is not communication to MySQL database. In every pc I have to install Labwindows/CVI. Some to help regarding this.
    Regards
    Anilkumar 

    Hello,
    There is a workaround posted for this error on the following threads:
    http://social.technet.microsoft.com/Forums/es-ES/ace2d644-dc82-424a-a608-4b4dc21065d4/setup-closed-with-exit-code-0x84c40013-silent-install-error-sql-server-2012-express-management?forum=sqlexpress
    http://social.msdn.microsoft.com/Forums/sqlserver/es-ES/0f5460d5-113f-4976-a43a-d2a7fdb7e304/sql-server-2008-developer-edition-install-fail-due-to-net-framework-35-missing?forum=sqlsetupandupgrade
    http://connect.microsoft.com/VisualStudio/feedback/details/472540/microsoft-sql-server-refuses-to-install
    Hope this helps.
    Regards,
    Alberto Morillo
    SQLCoffee.com

  • Mysql database connection with Labwindows/CVI 2009 sql toolkit

    Dear experienced users,
    I am using the following software/hardware:
    Windows 7/ Mysql database 5.6.15 64-bit with MySql ODBC 5.2 Ansi driver installed
    Labwindows/CVI 2009 with sql toolkit
    The user DSN of ODBC Data source administrator have been confiugred to one of mysql database. The test MYSQL Connector/ODBC is succesful.
    The Labwindows/CVI build setting is configure to debug64 after trying debug (32)
    The source code is from the example readtab.c with changes to the dsn I am testing
        hdbc = DBConnect ("DSN=dvd_collection");   
    The error message I have is confusing me.
    (it is in the attachd png)
    I thought it was due to the 64 bit mysql database. That's why I tried the 64 bit build from Labwiondws/CVI. I alsow tried Labview DB tools open connect.vi. It shows me the same error.
    Any suggestion is appreciated.
    Thanks,
    Jimmy
    Attachments:
    Capture.PNG ‏24 KB

    Jimmy
    I always use connection strings of the form "DSN=datasourcename;UID=database_user_id; PWD=database_user_password".
    Where:
    datasourcename = The name of the connection defined in the ODBC connection.
    database_user_id = One of the user identities created by the database administrator. Obviously the administrator will lock down the permissions appropriate to the task in hand.
    database_user_password = The password that identifies database_user_id, again set by the database administrator.
    Note that while it is obviously desireable to lock the permissions down as far as possible on the MySQL server, the more you do so, the slower the database will run, because of the way mySQL searches the permissions tables.

  • Help, Cannot connect to ODBC database using SQL Toolkit!

    Hello All,
    I am toying around with the SQL Toolkit evaluation (2.2 + the patch) and I am having difficulty.
    I ran the example program "connect" and it seems to work fine.
    However, I try to write my own program and I keep getting the same message:
    "Function DBConnect: (return value == -10 [0xFFFFFFF6]).
    Native error code - 2147467259 0x80004005
    The message differs from time to time, but the return value is constant.
    I am using both Microsoft SQL Server 2012 and MySQL.
    For MySQL I have installed the latest ODBC connector, 5.3.4. Inside the Control Panel/Data Sources(ODBC), I have a DSN named test_mysql in both User DSN and System DSN.
    I ran a test on the connection and the test passes. I am not sure if I should use the ansi or unicode driver, I have tried both with the same success.
    I am not sure I had configured the SQL Server connection properly, and will attempt that again.
    My CVI Code is simple enough:
    hdbc = DBConnect ("DSN=test_mysql"); 
    Every time I get a -10 from DBConnect. Either I have something configured wrong or I am missing something.
    Does anyone have any suggestions?
    Veni Vidi Duci
    Solved!
    Go to Solution.

    Update 2:
    After getting off the phone with Tech Support the problem has been identified!
    LabWindows SQL toolkit requires 32 bit DNS. My PC is a 64 bit, so my DNS manager defaulted to 64 bit.
    I needed to use the 32 bit DNS manager when working with the toolkit.
    Once I created my DNS connections using the 32-bit version of the ODBC Datga Source manager, everything worked fine.
    See this tech note:
    http://digital.ni.com/public.nsf/allkb/E7984C0DA0F0E65086257694005B4CB7
    Veni Vidi Duci

  • DBPutRecord Error in SQL Toolkit 2.0 for Mysql

    Dear All
    I am using Labwindows/CVI 7.1.1 with SQL Toolkit 2.0. I have facing problem in DBPutRecord in database.
    First I mapped the Table. While putting Records in table I am facing native Error Code 2147467259.
    I can Get the Datas from Table using bound funtion
    But Same function and method working fine in CVI 5.5.
    Please some one give me the Solution.

    kindly refer this and this knowledgebase
    Shreyas Hebbare
    Shreyas Technologies
    India

  • MySQL database with SQL Toolkit

    Hi,
    we are using CVI 2012 and the SQL Toolkit 2.2 and we want to connect to a MySQL database.
    The MySQL database was created with MySQLServer. When we try to connect with DBConnect we get an error.
    How can we connect the MySQL Database?
    What do we have to type in the connection string in DBConnect? Is it the name of the database, the path to the database or anything else?
    Does any one have experience with the SQL toolkit?
    Thanks in advance
    Oliver
    Solved!
    Go to Solution.

    You need to install the mysql connector odbc and then create an ODBC dns for your database.
    control panel, administrative, odbc

  • SQL toolkit 2.2 Stored Procedure Memory Leaks

    Hi
    we are using CVI 2012 and SQL Toolkit 2.2. My db is "MySql 5.5.28" and I use "MySQL Connector/ODBC 5.2(w)"
    I use only stored procedure (with and without the output parameters).  If I call continuously a stored procedure,
    with Sql toolkit code, I have memory leaks!! 
    My code (without error handler) is:
    // iDbConnId is the handle of DBConnect() called when program starts
    iStmt = DBPrepareSQL(iDbConnId, "spGetPrData");
    DBSetStatementAttribute(iStmt, ATTR_DB_STMT_COMMAND_TYPE, DB_COMMAND_STORED_PROC);
    DBExecutePreparedSQL(iStmt);
    DBBindColLongLong(iStmt, 1, &llPrId, &lStatus1);
    DBBindColInt(iStmt, 2, &iIpPort, &lStatus2);
    while(DBFetchNext(iStmt) != DB_EOF)
        //get data
    DBClosePreparedSQL(iStmt);
    DBDiscardSQLStatement(iStmt);
    If I call the same stored procedure by sql code ("CALL spProcedure()")
    I don't have memory leaks!!
    The code is (without error handler):
    // iDbConnId is the handle of DBConnect() called when program starts
    iStmt = DBActivateSQL(iDbConnId, "CALL spGetPrData();");
    DBBindColLongLong(iStmt, 1, &llPrId, &lStatus1);
    DBBindColInt(iStmt, 2, &iIpPort, &lStatus2);
    while(DBFetchNext(iStmt) != DB_EOF)
        //get data
    DBDeactivateSQL (iStmt)
    It seems to me that the DBDeactivateSQL function free the memory correctly,
    while the functions DBClosePreparedSQL and DBDiscardSQLStatement do not release properly the memory,
    (or I use improperly the library functions!!!)
    I also have a question to ask:
    Can I open and close the connection every time I connect to the database or is it mandatory to open and close it just one time?
    How can I check the status of the database connection, if is mandatory to open and close the db connection just one time?
    Thanks for your help.
    Best Regards
    Patrizio

    Hi,
    one of the functions "DBClosePreparedSQL and DBDiscardSQLStatement" is a known problem. In fact, there is a CAR (Corrective Action Request 91490) reporting the problem. What version of the toolkit are you using?
    About this function you refer to the manual:
    http://digital.ni.com/manuals.nsf/websearch/D3DF4019471D3A9386256B3C006CDC78
    Where functions are described. To avoid memory leaks DBDeactivateSQL must be used. DBDeactivateSQL is equivalent to calling DBCloseSQLStatement, then DBDiscardSQLStatement. DBDeativateSQL will work at all for parameterized SQL, as well.
    Regarding the connection mode advice to you is to open the connection once and close it at the end of your operations. What do you mean with "state of the database connection"? Remember that if you have connection problems or something goes wrong, the errors appears in any point in your code where you query the database. Bye
    Mario

  • Memory problem sql toolkit

    Hi
    we are using CVI 2012 and SQL Toolkit 2.2. Once a minute we are searching a SQL database for a special record and we update the data in this record. After updating we close the database. Each time we do this procedure we see in the taskmanager that the memory our program needs increases.
    After a couple of minutes (20-30) we get a memory error message.
    Does anybody know if this is a know problem or does anyone can help us?
    Thanks in advance
    Oliver
    here is some of the code:
        hdbc = DBConnect(DATABASE_STRING);
        hsql = DBActivateSQL(hdbc, "SELECT * FROM `data_l01`");
        rw = DBBindColChar(hsql, SQL_DATE, 32,        cDB_Date,            &iDB_Date_State, "");
        rw = DBBindColChar(hsql, SQL_TIME, 32,        cDB_Time,            &iDB_Time_State, "");
        rw = DBBindColInt(hsql, SQL_SPEED,            &iDB_Clock,            &iDB_Clock_State);
        // Flag, ob der Eintrag gefunden wurde loeschen
        iFoundFlag = 0;
        // Find the record we want to update
        while((rw = DBFetchNext(hsql)) == DB_SUCCESS)
            if( (StrICmpWithoutSurrWhiteSpace(cDB_Date, cDate) == 0) &&
                (StrICmpWithoutSurrWhiteSpace(cDB_Time, cTime) == 0))
                // Flag, ob der Eintrag gefunden wurde setzen
                iFoundFlag = 1;
                break;
            } // Ende von Find the record we want to update
            // Daten uebernehmen
            iDB_Clock            = iClock;
            // Insert the record into the database
            rw = DBPutRecord(hsql);
            rw = DBDeactivateSQL(hsql);
            rw = DBDisconnect(hdbc);
    Solved!
    Go to Solution.

    Hello Raphael,
    yes I came to the same point.
    Last week I was at our customer and I modified the code that the database will be opened only once during the startup and closed with the programm end. The access to the database is done in a thread.That means that the database is open the whole time.
    After this modification there was no more problem with the leak of memory. I watched the taskmanager a long time but there was no more rising memory
    Thanks a lot for your help.
    greetings
    Oliver

  • SQL Toolkit sur Windows x64

    Bonjour,
    Nous avons acquis la mise à jour LabWindows/CVI 2010 récemment, devons-nous aussi mettre à jour la version de l'instrument SQL en notre possession pour pouvoir accéder à des Bases de Données installées sur des machines Windows 64 bits ou 32 bits et depuis des machines qui elles aussi peuvent être sous Windows 32 bits ou 64 bits ?
    Notre version se nomme "SQL Toolkit v2.05" et le fichier "cvi_db.fp" est daté du 21/12/1999.
    Merci de vos conseils,
    Franck

    Unfortunately, I don't speak French so I hope you can understand this reply. The latest version of the SQL toolkit is version 2.2 which was released last year and is available here: http://sine.ni.com/nips/cds/view/p/lang/en/nid/11128
    It includes support for x86 and x64 although you ought to be aware that not all database providers offer x64 drivers for their databases. That's not anything CVI has control over though. As new x64 drivers are released, they should work with the SQL toolkit.
    Kevin B.
    National Instruments

  • SQL toolkit Win7 connection problem

    I'm using CVI 2013 and the SQL toolkit (2.2) tto connect to a mySQL database.  I can connect fine using my development computer, but not with the target one.  Both computers are running 64-bit Windows 7 Professional (SP1).  I was initially using the 64-bit ODBC drivers (mysql-connector-odbc-5.3.2-win64.msi) on both machines.  After I had trouble I found a Knowledge Base article that indicated I should probably be using the 32-bit one instead.  So I removed the drivers from the target and installed the 32-bit ones using odbcad32.exe found in Windows/SysWOW64.  No change.
    I'm using the browser2.prj sample project included with the SQL toolkit (by default at: C:\Users\Public\Documents\National Instruments\CVI\samples\sql\apps) to test the functionality of the SQL toolkit.  I build a distribution kit including the Shared Run-Time Engine on the development machine and install that on the target.  I have traced the problem to the call for DBSources() - it returns a -100 (which, handily, is not amoung the list of database error codes).
    On both machines the ODBC drivers appear to be working.  I can get to the database using Control Panel->Administrative Tools->Data Sources (ODBC).  Selecting the database under either User DSN or System DSN and then clicking Configure will open the MySQL Connector/ODBC Data Source Connection window.  Clicking Test in that window will connect to the database.  
    So the problem seems to lie in the way that CVI connects to the database.  I'm clueless at this time, so any suggestions would be greatly appreciated.
    Solved!
    Go to Solution.

    Sorry if this is a stupid question:
    Have you followed the instructions in Help->Library Reference->SQL Toolkit Library->SQL Language Reference->Distributing an SQL Toolkit Executable or DLL ?
    Or is this an error you are getting despite following those instructions?

Maybe you are looking for

  • Icloud shows wrong apple id , how do i change it

    icloud shows wron apple id , how do i change it to the correct apple id

  • When you buy music, do you also get the cd in the mail?

    When you buy a cd, is it only downloaded or do you also get the cd in the mail?

  • Adobe reader xi stopped working

    Question?  I tried to print a statement this morning with Adobe Reader XI.  A screen appeared telling me that Adobe Reader XI had stopped working and that windows was checking for a problem.  I thought I could just download a new Adobe Reader XI but

  • Adjustement layer on one layer

    Hi, Automatically, Adjustment Layer applies on all layers below. How can I apply an Adjustment Layer to only one of the layer below? EX. from bottom to top, I have Layer #1, #2 and #3. This order is important. I created an Adjustment layer on top of

  • No puedo incluir musica en el iphone

    Buenas a todos, Me explico, a dia de hoy soy incapaz de incluir musica en mi iphone, incluida la comprada, ya sea arrastrando sobre el icono de musica en el itunes o en el caso de las compradas de sincronizar lo comprado. Al arrastrar musica queda co