Home > database >  Pb window can't use the "add" button to add data
Pb window can't use the "add" button to add data

Time:09-22

Window is equipped with three sle_1 respectively, and the static text box name sle_2, sle_3, set the "add" button below, clicked event code
As follows: establishing ASA database each attribute with char)
//define string, used to store the student id, name and age
String sno, sna, age;
Sno=sle_1. Text;
Sna=sle_2. Text;
Age=sle_3. Text;
//insert statement
Insert Into student Values (sno, : sna, : age);
//if successfully added, is to commit the transaction
If the SQLCA. SQLNRows & gt; 0 then
Commit the using the SQLCA;
MessageBox (" congratulations!" , "data add success!" );
Close (xsxx_w);
Xsxxx_w. My_dw. Retrieve ()
The else
Add//not a success, the pop-up error message box
MessageBox (" error!" , "added data failed, please check the input data!" );
End the if


Always remind: "add data failed, please check the input data!" ,,, again and again checked still not solve for a long time, please everyone a great god help!!

CodePudding user response:

String sno, sna, age;
Sno=sle_1. Text;
Sna=sle_2. Text;
Age=sle_3. Text;
//insert statement

The sqlca. The autocommit=false

Insert Into student Values (sno, : sna, : age);
//if successfully added, is to commit the transaction
If the SQLCA. SQLcode & gt; 0 then
Commit the using the SQLCA;
MessageBox (" congratulations!" , "data add success!" );
Close (xsxx_w);
Xsxxx_w. My_dw. Retrieve ()
The else
The rollback using sqlca;
Add//not a success, the pop-up error message box
MessageBox (" error!" , "added data failed, please check the input data!" );
End the if

CodePudding user response:

//insert statement
Insert Into student Values (sno, : sna, : age);
using the sqlca.

CodePudding user response:

//insert statement
Insert Into student Values (sno, : sna, : age) using the sqlca.

CodePudding user response:

Testing can be MessageBox (' mistakes', '... '+ sqlca. Sqlerrtext) that can show the error message,

CodePudding user response:

Still not yet

CodePudding user response:

Testing can be MessageBox (' mistakes', '... '+ sqlca. Sqlerrtext) that can show the error message,

CodePudding user response:

See the sqlca sqlerrtext is what, stick it out

CodePudding user response:

The database connection is established

CodePudding user response:

Why use the SQLCA. SQLNRows to determine success or not? I have been use the sqlca. Judge the sqlcode.

CodePudding user response:

There is a problem, error before jumping messagebox, should first do a rollback

CodePudding user response:

The sqlca. Sqlerrtext

CodePudding user response:

 string sno, sna, age 
Sno=trim (sle_1. Text)
Sna=trim (sle_2. Text)
Age=trim (sle_3. Text)

If isnull (sle_1. Text) or trim (sle_1. Text)="" then
Messagebox (" tips! ", "is empty, please enter")
Retrun
End the if
If isnull (sle_2. Text) or trim (sle_2. Text)="" then
Messagebox (" tips! ", "is empty, please enter")
Retrun
End the if
If isnull (sle_3. Text) or trim (sle_3. Text)="" then
Messagebox (" tips! ", "is empty, please enter")
Retrun
End the if
//insert statement

The sqlca. The autocommit=false
If
Insert Into student (field 1, 2, and field 3) Values (: sno, sna, : age) using the sqlca.//such as field 1 is growth will be cancelled automatically sno value of Insert Insert Into student (field 2, 3) field Values (sna, : age) using the sqlca.
//if successfully added, is to commit the transaction
If the SQLCA. SQLcode=0 then
Commit the using the SQLCA;
MessageBox (" congratulations!" , "data add success!" );
Close (xsxx_w);
Xsxxx_w. My_dw. Retrieve ()
The else
If the SQLCA. SQLcode=1 then
The rollback using sqlca;
Add//not a success, the pop-up error message box
MessageBox (" error!" , "added data failed, please check the input data!" );
The else
MessageBox (" 100!" ., "Fetched row not found!" );
End the if
End the if

CodePudding user response:

SQLCA SQLNRows is used to determine the update after the number of rows to success

CodePudding user response:

Sqlca sqlcode doing with this judgment,
If the sqlca. Sqlcode=0 then//this is to save a success
commit;
The else
Messagebox (" insert error ", "error message is:" + string (sqlca. Sqlerrtext))//this is the database itself quoted error
The rollback.
end if

CodePudding user response:

Using messagebox (string (sqlca sqlcode), the sqlca. Sqlerrtext) look at the specific reason for the error

CodePudding user response:

reference 14 floor response:
sqlca. Sqlcode doing with this judgment,
If the sqlca. Sqlcode=0 then//this is to save a success
commit;
The else
Messagebox (" insert error ", "error message is:" + string (sqlca. Sqlerrtext))//this is the database itself quoted error
The rollback.
End the if


String ls_err

If the sqlca. Sqlcode=0 then//this is to save a success
commit;
The else
Ls_err=sqlca. Sqlerrtext
The rollback.
Messagebox (" insert error ", "error message is:" + ls_err//this is the database itself reported an error
End the if

General is to roll back data first, play prompt dialog box, which can avoid long time of the transaction, takes up resources, lead to process jams,

CodePudding user response:

Submitted after the success had only then can have the SQLCA SQLNRows, not according to this judgment whether to submit
  • Related