Recent

Author Topic: [ Is it possible to use "Alter Table Add column....." on run time ]  (Read 2000 times)

bleung

  • New member
  • *
  • Posts: 7
I am working on a project, which uses Lazarus with MS Access thru ODBC.  I need to alter the table for adding columns (number of columns adding will be depending on the number of rule files existing) at the run time.  I have tried to use "Alter table add column......." for doing that; but I got the error as ".....Cannot open a non-select statement....".

I have searched many website but cannot really find the details of the usage for the SQL command "Alter Table...Add Column....".  I have doubt that can I use "Alter Table ... Add Column..." SQL command while the RUN TIME?

Thanks

Lazarus 1.0.6, fpc 2.6.0, Win 7 64bit
Lazarus ver 1.0.8
FPC ver 2.6.2
x86_64-win64-win32/win64

paweld

  • Full Member
  • ***
  • Posts: 245
Re: [ Is it possible to use "Alter Table Add column....." on run time ]
« Reply #1 on: February 22, 2013, 05:20:23 pm »
Use TSQLScript
Best regards
paweld

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: [ Is it possible to use "Alter Table Add column....." on run time ]
« Reply #2 on: February 23, 2013, 08:30:37 am »
Good suggestion by pawel.

Another thing: you are probably opening the query with the alter table statement. Don't. Execute it (ExecSQL method), see. e.g.
http://wiki.lazarus.freepascal.org/Working_With_TSQLQuery#General

Also/for background, see the new FPC 2.6.2 documentation on sqldb
http://sourceforge.net/projects/freepascal/files/Documentation/2.6.2/doc-pdf.zip/download
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

 

TinyPortal © 2005-2018