Forum > Databases

[SOLVED]SQLQuery1 create table errors out - what's wrong

(1/2) > >>

What I can do:
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  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- SQLQuery1.SQL.Text:=' CREATE TABLE Words' +      ' (w_IDX int NOT NULL UNIQUE, '+      '  w_Text varchar(80) Null, ' +      '  w_Phonix varchar(80) Null) ';  SQLQuery1.Open; alwas get error saying field not correct

dsiders:

--- Quote from: What I can do 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  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- SQLQuery1.SQL.Text:=' CREATE TABLE Words' +      ' (w_IDX int NOT NULL UNIQUE, '+      '  w_Text varchar(80) Null, ' +      '  w_Phonix varchar(80) Null) ';  SQLQuery1.Open; alwas get error saying field not correct

--- End quote ---

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

Handoko:
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

What I can do:
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:
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

Navigation

[0] Message Index

[#] Next page

Go to full version