error in db

1
0
-1

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.

Question Tags: 

Answers

Kim Berghall answered error in db

1
0
-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.

radharani10jan_30583's picture

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 */

· Ullrich's picture

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.

Olan Knight answered error in db

1
0
-1

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