Recent

Author Topic: [SOLVED]SQLQuery1 create table errors out - what's wrong  (Read 1134 times)

What I can do

  • Full Member
  • ***
  • Posts: 152
[SOLVED]SQLQuery1 create table errors out - what's wrong
« on: May 14, 2024, 03:33:45 am »
I think this is the way to create a table in Access file *.mdb
OD:win10
compiler: Lazarus 3.2
Project create a new table in a test project
Code: Pascal  [Select][+][-]
  1.  SQLQuery1.SQL.Text:=' CREATE TABLE Words' +
  2.       ' (w_IDX int NOT NULL UNIQUE, '+
  3.       '  w_Text varchar(80) Null, ' +
  4.       '  w_Phonix varchar(80) Null) ';
  5.   SQLQuery1.Open;
alwas get error saying field not correct
« Last Edit: May 27, 2024, 08:28:54 pm by What I can do »

dsiders

  • Hero Member
  • *****
  • Posts: 1377
Re: SQLQuery1 create table errors out - what's wrong
« Reply #1 on: May 14, 2024, 04:08:57 am »
I think this is the way to create a table in Access file *.mdb
OD:win10
compiler: Lazarus 3.2
Project create a new table in a test project
Code: Pascal  [Select][+][-]
  1.  SQLQuery1.SQL.Text:=' CREATE TABLE Words' +
  2.       ' (w_IDX int NOT NULL UNIQUE, '+
  3.       '  w_Text varchar(80) Null, ' +
  4.       '  w_Phonix varchar(80) Null) ';
  5.   SQLQuery1.Open;
alwas get error saying field not correct

Open is expecting to find a dataset. Your SQL DDL statement doesn't return one.

Use ExecSql instead. https://lazarus-ccr.sourceforge.io/docs/fcl/sqldb/tcustomsqlquery.execsql.html
Preview the next Lazarus documentation release at: https://dsiders.gitlab.io/lazdocsnext

Handoko

  • Hero Member
  • *****
  • Posts: 5396
  • My goal: build my own game engine using Lazarus
Re: SQLQuery1 create table errors out - what's wrong
« Reply #2 on: May 14, 2024, 12:24:46 pm »
Here has a demo showing how to use SQL for creating, connecting, reading, adding, deleting and doing searching for SQLite:
https://forum.lazarus.freepascal.org/index.php/topic,65185.msg496461.html#msg496461

For creating tables, ExecuteDirect can be used, which is easier than ExecSQL:
https://docwiki.embarcadero.com/Libraries/Athens/en/Data.SqlExpr.TSQLConnection.ExecuteDirect
« Last Edit: May 14, 2024, 12:39:45 pm by Handoko »

What I can do

  • Full Member
  • ***
  • Posts: 152
Re: SQLQuery1 create table errors out - what's wrong
« Reply #3 on: May 14, 2024, 01:44:26 pm »
Thank you, Handoko
LOL, you don't know this but years ago I made a data base helper, where I can access any help info that I find. I paste into the data base and then use all the power of the DB Engine to sort, find, chop, etc.. You get the picture. I created a branch on the main tree called Handoko and man its getting BIG!

you da man!

What I can do

  • Full Member
  • ***
  • Posts: 152
Re: SQLQuery1 create table errors out - what's wrong
« Reply #4 on: May 14, 2024, 01:49:36 pm »
however I finally resolved my issue by
[Run] (Clean up and build)
I guess all my hard crashing messed something up so I now use this menu command after every hard crash.
but today I found a new issue
think I will post it as well.

thanks again

Handoko

  • Hero Member
  • *****
  • Posts: 5396
  • My goal: build my own game engine using Lazarus
Re: SQLQuery1 create table errors out - what's wrong
« Reply #5 on: May 14, 2024, 02:20:06 pm »
... I made a data base helper, where I can access any help info that I find. I paste into the data base and then use all the power of the DB Engine to sort, find, chop, etc..

Me too, wrote myself SideNote for storing text information that important to me. It is a stay on system tray program. This utility was written using Lazarus + TDbf. I already planned it to support images, spreadsheet files and URL links. I wanted to rewrite it to use SQLite but later I found myself busy had no time doing it.

What I can do

  • Full Member
  • ***
  • Posts: 152
Re: SQLQuery1 create table errors out - what's wrong
« Reply #6 on: May 14, 2024, 02:29:30 pm »
LOL, Yours is like a big filing cabinet with drawers and well organized folders but mine is like a trach can where every thing is stacked on top of it's self.

you rock!

 

TinyPortal © 2005-2018