Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Using a single connection to a MSSQL database

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

609 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