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 February 19th, 2013, 05:07 AM
Perran Perran is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 6 Perran User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 12 m 50 sec
Reputation Power: 0
[solved] Adding a Column/Field to an ADOTable

I have an ADOTable1 which is connected to an ms access table and I want to add a field/column to the ADOTable.

I have read other forum posts but haven't managed to get it to work.

I need to add a yes/no field and a number field.


Thanks in advance,
~Perran

Reply With Quote
  #2  
Old February 19th, 2013, 08:48 AM
majlumbo majlumbo is online now
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2008
Posts: 251 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 50 m 14 sec
Reputation Power: 5
I'm not sure I understand what the actual question is. If it's about how to add the fields to your Access database, I would highly recommend that you do that through Access, not through your program. Adding the columns is a one time event, so once it's added, you wouldn't need to run that code ever again. Kind of a waste to code it, only to run it once, when using Access itself is so much easier.

As far as having Delphi "see" the changes, it does so, but you will need to take into consideration your query's actual SQL and which fields were added in the field's editor.

If your SQL iterates the actual columns you want to return Select <column1>, ... versus select *, then you will need to add the new columns to the select list i.e. Select <column1>, ..., <newcolumn1>, <newcolumn2> from ...

To add the new fields to the fields editor, double click on the table or query component, right click in the field's editor and select add all fields. Any new fields will be added.

Reply With Quote
  #3  
Old February 20th, 2013, 06:05 AM
Perran Perran is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 6 Perran User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 12 m 50 sec
Reputation Power: 0
I need to add a field to the ADOTable in code so that the user can add a field by pressing a button so that they don't have to create one in access and program it in.

Reply With Quote
  #4  
Old February 20th, 2013, 08:50 AM
Perran Perran is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 6 Perran User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 12 m 50 sec
Reputation Power: 0
I have solved this. I used SQL:

ADOQTable1.Close;
ADOQTable1.SQL.Clear;
ADOQTable1.SQL.Add ('ALTER TABLE MyTable ADD COLUMN [' + mystring + '] YESNO');
ADOQTable1.ExecSQL;

thanks anyway!

Reply With Quote
  #5  
Old February 20th, 2013, 08:54 AM
majlumbo majlumbo is online now
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2008
Posts: 251 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 50 m 14 sec
Reputation Power: 5
Quote:
Originally Posted by Perran
I have solved this. I used SQL:

ADOQTable1.Close;
ADOQTable1.SQL.Clear;
ADOQTable1.SQL.Add ('ALTER TABLE MyTable ADD COLUMN [' + mystring + '] YESNO');
ADOQTable1.ExecSQL;

thanks anyway!

This will work, but if you're adding the column via a button press, what prevents the user from pressing it twice (or more)?

Reply With Quote
  #6  
Old February 22nd, 2013, 08:39 AM
Perran Perran is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 6 Perran User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 12 m 50 sec
Reputation Power: 0
It doesn't matter because the string that it uses for the column name changes every time.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreDelphi Programming > Adding a Column/Field to an ADOTable

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