?
Solved

Using a single connection to a MSSQL database

Posted on 1997-09-16
1
Medium Priority
?
190 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 300 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

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