Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 500455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:05:20+00:00 2026-05-13T06:05:20+00:00

Form1 connects to a database and keeps the connection in a published property Form1->DBSession.

  • 0

Form1 connects to a database and keeps the connection in a published property Form1->DBSession.

In the project source I would like to make sure that this session is closed, even if the program is aborted throwing an exception (in a library).

My code includes the form using

USEFORM("fForm1.cpp", Form1); 

When writing this code in WinMain

try {
   Application->Initialize();
   Application->CreateForm( __classid(TForm1), &Form1 );
   Application->Run();
} 
__finally
  {  Form1->DBSession->Close(); } 

the compiler does not compile as it does not know TForm1. I cannot include the header file as I need to use USEFORM and get a redeclaration error including.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T06:05:21+00:00Added an answer on May 13, 2026 at 6:05 am

    You do not need to add a try..finally block inside of WinMain(). After WinMain() exits, all active TForm objects are automatically freed. Simply have your MainForm close the DBSession inside its destructor.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to make sure that everything I know about UTF-8 is correct.
I am working on a Windows Form that connects to a ASP.NET membership database
I've been writing python scripts that run locally. I would now like to offer
<?php // code that connects to database ?> <table> <form method=get action=processorder.php> <?php while
I am buiding an application in Java that connects to a variety of databases,
For some reason my script connects to the database and has no errors however
I have the following code: <script type=text/javascript> function SubmitForm() { form1.submit(); } function ShowResponse()
Windows Forms allows you to develop Components, non-visual elements that can have a designer.
I have no problems setting up a regular (Windows Forms or Console) project in
Please forgive my long question. I have an idea for a design that I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.