Solved

Using a single connection to a MSSQL database

Posted on 1997-09-16
1
188 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 1

Accepted Solution

by:
anilms earned 100 total points
ID: 1345008
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

695 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