Hi Radharani,
Here's a sample code for saving data to the database:
//************************************************************
// Variable Declarations
//************************************************************
STRING ls_username
STRING ls_password
INTEGER li_count
//We Initialize the variables by trimming blank spaces from the Single Line Edit Controls
ls_username = TRIM(sle_username.text)
ls_password = TRIM(sle_password.text)
//************************************************************
// Logic of the Script
//************************************************************
//Insert the values into the Database
INSERT INTO USERS (USER_ID, USERNAME, PASSWORD)
VALUES (123, :ls_username, :ls_password)
USING SQLCA;
//Check for any database errors
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)
ELSE
//If everything OK, Notify the user
MessageBox("Data saved!", "The data has been successfully saved to the database!")
END IF
Remember: It's always good practice to check if the data already exists before saving it.
Regards,
I just want to learn how to connect to db and save data by creatig one sample program .
But i am facing error in above code database error.
This is the best way to understand the concepts for PB.
Regards
David