LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

sqlite

Solved!
Go to solution

Hi

 

I downloaded the latest sqlite file and currently trying to use sqlite3 but every time i try to add a table i get an error 

 

" "sqlite3.c", line 70193, col 30, thread id 0x00000F50:   Pointer arithmetic involving null pointer." in sqlite3_prepare_v2() function.

 

This is my current coding :

int main()
{
sqlite3_config(SQLITE_CONFIG_SINGLETHREAD);
sqlite3_initialize();
sqlite3_open("test.db", &DB);

Str=CreateTable("Info");//Creates SQL Query and is correct
StepQuery(Str); //View Below
sqlite3_close(DB);
}
//----------------------------------------------------------------//
void StepQuery(char *query)
{
const char *query_tail=NULL;
int MaxQueryLength=499;
sqlite3_stmt *stmt=NULL;
int i,result,numCols=0;
const char **results=NULL;
const char **columnNames=NULL;
const unsigned char* Columntext;
/* We skip the other variable declarations and the code to open the database */

//execute query
result=sqlite3_prepare_v2(DB, query, MaxQueryLength, &stmt, &query_tail);//This in this function is the where im receiving the error

do {
result=sqlite3_step(stmt);//if null pointer error skipped crashes over here

if (result==SQLITE_ROW){
for (i=0; i<numCols; i++){
/* Do something with this field in the results; I guess we'll print it.*/
Columntext=sqlite3_column_text(stmt, i);

}
printf("\n");
}
} while (result==SQLITE_ROW);
sqlite3_finalize(stmt);
}

 Can some body please help me understand why this is happening ?

 

 

Message Edited by Shako on 08-04-2009 11:25 AM
Help share your knowlegde
0 Kudos
Message 1 of 4
(4,219 Views)

Are you getting this message when trying to run a debug build? If so then there might be an issue with the const qualifier on the passed parameters into the function - these have been known to cause problems with the CVI debug framework code in the past. Try removing the qualfier from the definitions and see if you still get the error.

 

JR

0 Kudos
Message 2 of 4
(4,207 Views)

I have sovled the problem.

Here is where the problem was and how i sovled it :

#if defined(__GNUC__) # if defined(HAVE_STDINT_H) # define SQLITE_INT_TO_PTR(X) ((void*)(intptr_t)(X)) # define SQLITE_PTR_TO_INT(X) ((int)(intptr_t)(X)) # else # define SQLITE_INT_TO_PTR(X) ((void*)(X)) # define SQLITE_PTR_TO_INT(X) ((int)(X)) # endif #else # define SQLITE_INT_TO_PTR(X) ((void*)(X)) # define SQLITE_PTR_TO_INT(X) ((int)(X)) //# define SQLITE_INT_TO_PTR(X) ((void*)&((char*)0)[X]) //# define SQLITE_PTR_TO_INT(X) ((int)(((char*)X)-(char*)0)) #endif

 

 

 

 

Help share your knowlegde
0 Kudos
Message 3 of 4
(4,205 Views)
Solution
Accepted by topic author Shako

Thanks for the input.

 

I have sovled the problem.

Here is where the problem was and how i sovled it :

 

#if defined(__GNUC__) # if defined(HAVE_STDINT_H) # define SQLITE_INT_TO_PTR(X) ((void*)(intptr_t)(X)) # define SQLITE_PTR_TO_INT(X) ((int)(intptr_t)(X)) # else # define SQLITE_INT_TO_PTR(X) ((void*)(X)) # define SQLITE_PTR_TO_INT(X) ((int)(X)) # endif #else # define SQLITE_INT_TO_PTR(X) ((void*)(X)) # define SQLITE_PTR_TO_INT(X) ((int)(X)) //# define SQLITE_INT_TO_PTR(X) ((void*)&((char*)0)[X]) //# define SQLITE_PTR_TO_INT(X) ((int)(((char*)X)-(char*)0)) #endif

 

 

 

Help share your knowlegde
0 Kudos
Message 4 of 4
(4,205 Views)