Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 37
Registered: ‎05-27-2010
My Device: 9700 Storm
Accepted Solution

DatabaseBindingException

Hi All,

 

I have to bind a variable to a insert statement. As far as my knowledge goes, there's nothing wrong in my statement. But, it's showing "net.rim.device.api.database.DatabaseBindingException: Invalid parameter index". Please see my statement

 

Statement createSDStmt = database.createStatement("CREATE TABLE 'SoDetails'('Sono' nvarchar(8), 'SoInfo' nvarchar(15), 'customer' nvarchar(100), 'addr' nvarchar(100), 'addr2' nvarchar(100), 'city' nvarchar(100), 'terms' nvarchar(100), 'contact' nvarchar(100), 'problem' nvarchar(100), 'comments' nvarchar(100), 'ServCode' nvarchar(14), 'Status_Call' nvarchar(20), 'isupdate' bit, 'custno' nvarchar(16), 'calltype' nvarchar(8), 'Telephone' nvarchar(15), 'Telephone2' nvarchar(15))");

Statement insertStmt = database.createStatement("INSERT INTO SoDetails(Sono, SoInfo, customer, addr, addr2, city, terms, contact, problem, comments, ServCode, Status_Call, isupdate, custno, calltype, Telephone, Telephone2) VALUES ('"+strSDSoNo[index]+"', '"+strSDSoInfo[index]+"', ?, '"+strSDAddr[index]+"', '"+strSDAddr2[index]+"', '"+strSDCity[index]+"', '"+strSDTerms[index]+"', '"+strSDContact[index]+"', '"+strSDProblem[index]+"', '"+strSDComments[index]+"', '"+strSDServCode[index]+"', '"+strSDStatusCall[index]+"', 0, '"+strSDCustNo[index]+"', '"+strSDCallType[index]+"', '"+strSDPhone[index]+"', '"+strSDPhone2[index]+"')");

insertStmt.prepare();
insertStmt.bind(2, strSDCustName[index]);
insertStmt.execute();

 

When I hardcode the value,it's working fine. Can anyone say the reason for binding issue?

 

--------------------------------------------------------------------------------------
Justin Aloor

Feel free to press the Kudos Button to thank the user who helped you.
Please mark posts as solved if you found a solution.
Developer
Posts: 415
Registered: ‎07-28-2010
My Device: 8000
My Carrier: hi

Re: DatabaseBindingException

[ Edited ]

Hello,

             I give you link.

                   http://www.blackberry.com/developers/docs/6.0.0api/net/rim/device/api/database/package-summary.html

                    read its help you.

 thanks

  ajay

Highlighted
Developer
Posts: 37
Registered: ‎05-27-2010
My Device: 9700 Storm

Re: DatabaseBindingException

I got the solution. Here's this

 

There are two main ways to number the parameters: 
1. A question mark (?) in the statement causes each parameter to be numbered sequentially, starting from 1. 
2. A question mark followed by an integer (?NNN) in the statement provides each parameter with the number NNN. 

 

The second way worked for me !!!!! 

--------------------------------------------------------------------------------------
Justin Aloor

Feel free to press the Kudos Button to thank the user who helped you.
Please mark posts as solved if you found a solution.
Developer
Posts: 415
Registered: ‎07-28-2010
My Device: 8000
My Carrier: hi

Re: DatabaseBindingException

ok. good.Smiley Happy