| |

VerySource

 Forgot password?
 Register
Search
View: 3104|Reply: 11

BCB operates database to catch exceptions

[Copy link]

1

Threads

8

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-3-15 16:30:02
| Show all posts |Read mode
I use BCB to access SQL Server. The new record does not catch the error returned by SQL. Please give pointers, thank you, :)
try
{
    this-> ADOQuery1-> Open ();
    this-> ADOQuery1-> Insert ();
     .....
    this-> ADOQuery1-> Post ();
    this-> ADOQuery1-> Close ();

}
catch (EDatabaseError * e) {
                ShowMessage ("Error");
                return;
        }
Reply

Use magic Report

0

Threads

27

Posts

24.00

Credits

Newbie

Rank: 1

Credits
24.00

 China

Post time: 2020-6-14 17:15:02
| Show all posts
catch(EDatabaseError *e) should
catch(EDatabaseError&e)
Reply

Use magic Report

1

Threads

8

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

 Author| Post time: 2020-6-17 22:30:01
| Show all posts
This is a newly added SQL statement. If there are duplicate records, it will be captured and prompted to have this record.
Reply

Use magic Report

1

Threads

8

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

 Author| Post time: 2020-6-18 05:45:01
| Show all posts
Now the program runs with an error as soon as there are duplicate records, the program is interrupted
Reply

Use magic Report

1

Threads

8

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

 Author| Post time: 2020-6-18 14:15:01
| Show all posts
Its prompt message is the EOleException class, and it cannot be caught with it. :(
Reply

Use magic Report

0

Threads

27

Posts

24.00

Credits

Newbie

Rank: 1

Credits
24.00

 China

Post time: 2020-6-19 09:00:01
| Show all posts
catch(...)
Look at
Reply

Use magic Report

0

Threads

27

Posts

24.00

Credits

Newbie

Rank: 1

Credits
24.00

 China

Post time: 2020-6-19 10:45:01
| Show all posts
or
catch (Exception&exception)
Reply

Use magic Report

0

Threads

8

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-6-21 10:45:01
| Show all posts
try
{
    this->ADOQuery1->Open();
    this->ADOQuery1->Insert();
     .....
    this->ADOQuery1->Post();
    this->ADOQuery1->Close();

}
catch(Exception&e){
                ShowMessage(e.Message);
                return;
        }
Reply

Use magic Report

1

Threads

8

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 Unknown

 Author| Post time: 2020-6-21 18:45:01
| Show all posts
It still doesn't work.
Reply

Use magic Report

0

Threads

11

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-6-22 17:15:01
| Show all posts
try
{
...
}
catch(Exception&E)
{
  ShowMessage("Here is the best place to write the code where the function is located to help you find the place of the error" +E.Message);//It is better to add E.Message here, because if you do not add this sentence, only show your error Prompt message, you do not know why it is wrong

}
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list