From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

SQL Toolkit DBCreateParamChar problem with Interbase

Hye.
 
I have problems with using of CVI SQL TOOLKIT DBCreateParamChar() statment.
 
I create a stored procedure "My_Proc_Stoc" on my database wich have a char(5) input parameter.
I use the DBCreateParamChar() to set the input parameter but I have some problems.
 
This is a example of my source code :
 
int rescode;
char par[6];
...
   hstmt = BDPreparedSQL(handle, "My_Proc_Stoc);
   rescode = DBCreateParamChar(hstmt,"",DB_PARAM_INPUT,par,"");
   rescode = DBExecutePreparedSQL(hdbc);
 
I the "par" variable is not set the statment works, but its not what i want to do.
 
When I set the "Par variable like this the statment works :
par[1]='1';
par[2]='2';
par[3]='3';
par[4]='4';
par[5]='5';
 
When I set the "Par variable like this the statment doesn't work :
par[0]='1';     // Problems when trying to set the first element of the char table
par[1]='2';
par[2]='3';
par[3]='4';
par[4]='5';
par[5]='6';
 
Do you know what is the problem in the second example ?
have you examples of use ?
 
PS : I have used stored procedures whith other input types (int, short, .. ) and it works well. The problem was on tying to set an input Char parameter.
 
Thanks.
 
 

Message Edité par lio33 le 10-26-2005 05:52 AM

0 Kudos
Message 1 of 3
(2,806 Views)
 
Problem of use of char[].
Must use the strcpy fonction before use the DBCreateParamChar() Statment
 
strcpy(par,"text to pass in stored procedure parameter");
resCode=DbCreateParamChar( hstmt, "", DB_PARAM_INPUT, par, sizeof(par));
 
 
0 Kudos
Message 2 of 3
(2,795 Views)
While your second post shows what is probably the best solution, I suspect the issue with the setup in the first post is that the string is not null terminated.
 
par[0]='1';
par[1]='2';
par[2]='3';
par[3]='4';
par[4]='5';
par[5]=0;
would create a terminated string.
0 Kudos
Message 3 of 3
(2,788 Views)