Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI
This Document is not yet Rated  Rate this Document

Why Do I Get "Native error code message" When I Call a LabWindows/CVI SQL Toolkit Function in My Program?

Primary Software: LabWindows/CVI Add-ons>>Enterprise Connectivity Toolset
Primary Software Version: 1.1
Primary Software Fixed Version: N/A
Secondary Software: N/A

Problem: When calling some LabWindows/CVI SQL Toolkit functions in my program, I get a "Native error code message". Why is that?

Solution: A "Native error code" is an error that is returned by the underlying database provider (i.e., the database driver you are using to communicate with your database file) or by the underlying Windows ADO (ActiveX Data Objects) layer. This type of error does not indicate that there is something inherently wrong with the SQL Toolkit or CVI itself, but rather it indicates that the operation you are trying to perform with your particular database is not supported in the manner that you tried to implement it. Most often, it is caused by an improper SQL statement trying to pass an improper datatype to the database, or by trying to execute a specific function of the database incorrectly.

National Instruments does not provide database provider-specific technical support for trying to troubleshoot what a particular database does and does not support when interacting with it through the SQL Toolkit. This type of support should be sought out through the 3rd party database provider. What the SQL Toolkit does provide, is a set of useful error detection and interpretation functions that might lead you to a possible explanation for what is going on with your underlying database provider.

To determine if you are getting a particular type of error from a function call, look at the following information quoted directly from the LabWindows/CVI SQL Toolkit Reference Manual (page 3-12):

    The SQL Library functions return one of three types of values: result codes, handles, and data. You can compare a result code with DB_SUCCESS to determine if an error occurred. Handles refer to such items as database connections or activated SQL statements. If a function returns a handle, a value less than or equal to zero indicates an error. You can then call DBError to determine the error number. You also can call DBErrorMessage to get the text of the error message. For functions that return data, such as DBColumnName, you should call DBError to determine whether an error occurred.

    hdbc = DBConnect (hdbc); 
    if (hdbc <= 0) {
    errorCode = DBError();
    errorMsg = DBErrorMsg();
    printf("Error number %d\n%s\n", errorCode, errorMsg);
    }
Now, if you do determine that the error is a Native error (usually indicated by the return value of a call to DBError being equal to DB_ODBC_ERROR, DB_DBSYS_ERROR or DB_AUTOMATION_ERROR), you can then call the DBNativeError function to retrieve the Native error code that your database provider or ADO reported. You should then consult your database provider manual, the 3rd party developer, or the Microsoft ADO/ODBC technical support pages described below for more information as to what might have caused it to happen.

Related Links: Product Manuals: LabWindows/CVI SQL Toolkit Reference Manual (January 2002)

Microsoft Universal Data Access


Attachments:





Report Date: 07/25/2001
Last Updated: 02/02/2006
Document ID: 2BOERBEV

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
  1 2 3 4 5
Please Contact NI for all product and support inquiries.submit