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 statementInsert Into student Values (sno, : sna, : age);
using the sqlca.
CodePudding user response:
//insert statementInsert 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 yetCodePudding 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 outCodePudding user response:
The database connection is establishedCodePudding 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 rollbackCodePudding user response:
The sqlca. SqlerrtextCodePudding 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 successCodePudding 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 errorCodePudding user response: