1. radha rani
  2. PowerBuilder
  3. Wednesday, 11 April 2018 17:08 PM UTC

hi Everyone,

I am having database error in the below piece of code.

IF SQLCA.SQLCODE <> 0 THEN

   //If an error: notify the user

   MessageBox("Database Error!", "Error while saving data to the database. Error message: [" +STRING(SQLCA.SQLCODE) + "] - " + SQLCA.SQLERRTEXT)

..............................................

Please help me what need to checked in database.

Kim Berghall Accepted Answer Pending Moderation
  1. Wednesday, 11 April 2018 18:14 PM UTC
  2. PowerBuilder
  3. # 1

You just depend on the sqlerrtext and then display that to the user. The error could be from many things, like duplicate row, db constraint issues etc. there is not an exact error code for all the different conditions.

Comment
  1. radha rani
  2. Wednesday, 11 April 2018 18:46 PM UTC
Sorry I didnt got you..



 



Actually I want simple login code 



Username : text



Password ; text



button



when clicked button data get saved into the database(sql server 2012).



/*Powerbuilder ver 9 using */

  1. Helpful
  1. René Ullrich
  2. Thursday, 12 April 2018 05:09 AM UTC
We need more information to help you:



- What is the code (last database call) before your IF statement?



- What shows your MessageBox (what SQLCode and what SQLErrText)?



The SQLCode and SQLErrText should you say what was wrong.

  1. Helpful
There are no comments made yet.
Olan Knight Accepted Answer Pending Moderation
  1. Wednesday, 18 April 2018 17:57 PM UTC
  2. PowerBuilder
  3. # 2

Try this:
 

string     ls_txt

IF (SQLCA.SQLCODE <> 0) THEN

   //If an error: notify the user

     ls_txt = "Error while saving data to the database. Error message: [" + STRING (SQLCA.SQLCODE) + "] - " + SQLCA.SQLERRTEXT

   MessageBox("Database Error!", ls_txt)

END IF

 

If nothing else, this allows you to put a breakpoint where you populate LS_TXT.


Good Luck,

Olan

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.