Delphi Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreDelphi Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 1st, 2012, 09:00 AM
chisoko_n chisoko_n is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2009
Posts: 77 chisoko_n User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 h 17 m 50 sec
Reputation Power: 4
Facebook
Setting connection string adoQuery on formShow

Hi, Im making a program making use of an access database to enter participants into a database. I want my adoQueries connection string to be set on formShow and for the program to raise an exception if the database is not found.

Could someone help with an efficient coding method of doing this?. The location of the database is in the same folder as the application

Reply With Quote
  #2  
Old August 1st, 2012, 09:08 PM
Luthfi Luthfi is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2012
Posts: 134 Luthfi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 4 h 26 m
Reputation Power: 2
I believe the code would be straightforward. No decent approach would become so inefficient compared with the others. However I would like to remind you that OnShow event might be triggered multiple times. Unlike OnCreate. So, if you don't want the code to be executed multiple times, you need a little special care for it.

When you activate the queries and the corresponding database is not found, ADO itself will raise exception. You of course can customize the exception by capturing it and throw your own exception. First you have to find out the ADO's exception class for database missing. For this, just simulate a database missing situation.

Edit:
If you are using multiple TADOQuery (or any ado datasets), and they are connected to the same database, why don't you use a single TAdoConnection to define database connection?

Last edited by Luthfi : August 1st, 2012 at 09:11 PM.

Reply With Quote
  #3  
Old August 1st, 2012, 11:07 PM
majlumbo majlumbo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2008
Posts: 252 majlumbo User rank is Lance Corporal (50 - 100 Reputation Level)majlumbo User rank is Lance Corporal (50 - 100 Reputation Level)majlumbo User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 2 Days 22 h 53 m 5 sec
Reputation Power: 5
I would add one thing to Luthfi's comment concerning your statement:
Quote:
The location of the database is in the same folder as the application


In Windows Vista and Windows 7, this would cause UAC issues since your application would need to have administrator rights to write to the program directory.

Reply With Quote
  #4  
Old August 2nd, 2012, 02:22 AM
chisoko_n chisoko_n is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2009
Posts: 77 chisoko_n User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 h 17 m 50 sec
Reputation Power: 4
Facebook
Quote:
Originally Posted by Luthfi
I believe the code would be straightforward. No decent approach would become so inefficient compared with the others. However I would like to remind you that OnShow event might be triggered multiple times. Unlike OnCreate. So, if you don't want the code to be executed multiple times, you need a little special care for it.

When you activate the queries and the corresponding database is not found, ADO itself will raise exception. You of course can customize the exception by capturing it and throw your own exception. First you have to find out the ADO's exception class for database missing. For this, just simulate a database missing situation.

Edit:
If you are using multiple TADOQuery (or any ado datasets), and they are connected to the same database, why don't you use a single TAdoConnection to define database connection?


I will try the adoConnection, and thank you for the help. Will reply if I encounter any problems

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreDelphi Programming > Setting connection string adoQuery on formShow

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap