Solved

Using a single connection to a MSSQL database

Posted on 1997-09-16
1
171 Views
Last Modified: 2010-04-04
I'm trying to write an application that uses a single connection to a MSSQL database server, for all its queries.

I'm currently pointing all my TTable objects at single TDatabase object. But what I find is that each time I open a new TTable it makes a new connection to the database server. So for example, on one form I need 5 TTable open at the same time, and hence I get 5 connections. What I would like is to use only one connection for all 5 TTables.

Is there a way to do this, and if there is what is it?
0
Comment
Question by:belgan
1 Comment
 
LVL 1

Accepted Solution

by:
anilms earned 100 total points
Comment Utility
Yes, you can do it. Assuming that you are connecting your TTable component to different DB Aware controls such as grids and edits in different forms, you can have one single TTable and DataSource in the main form. During run time, you can change the following properties to connect to different tables through the same connection:

First make the tables's active property false.
Change the Table name to the new table name
Then make the table's active property true.

I would , however, suggest that you use the TQuery component instead. In fact you are supposed to use TQuery component when you are working with SQL databases. Then you will not have this problem of new connections.  The TQuery component is used just like the TTable component, the difference being you enter the SQL property and then execute it. The TQuery component then fills up your data aware connected controls such as dbEdit and dbGrid.

If you still have further problems, please contact me thro email at anil_ms@hotmail.com
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video discusses moving either the default database or any database to a new volume.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now