Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI
3 rating:
 1.33 out of 5     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, I get a "Native error code message". What is the source of this error?

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 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, such as 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 providers themselves. What the SQL Toolkit does provide though 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. In order 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: Microsoft Universal Data Access
KnowledgeBase 1YKI602L: Which SQL Functions Can I Use with the LabWindows/CVI SQL Toolkit 2.0?
KnowledgeBase 1LQ7KVUT: Programmatically Specifying an Arbitrary File as the Data Source with the CVI-SQL Toolkit
KnowledgeBase 2QDEBL6I: Why Do I Get Error -2147352573 When I Run SQL Toolkit 2.0 Examples for LabWindows/CVI Version 6.0?


Attachments:





Report Date: 07/25/2001
Last Updated: 12/06/2004
Document ID: 2BOEMOEV

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