Sanity Check Please on SQL Statement lazarus / 16-Databases ---------------------------------------------------------------------- daveinhull · 2019-01-12 14:22 Hi, I think I'm going crazy! I have an SQL statement to a MS Access DB as follows Code: SQL  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i SELECT Table1.EntriesFROM Table1WHERE (((Table1.Entries)="Test1")); It works perfectly in Access, but in Pascal it returns a "Too few parameters. Expected 1. I just can't see what I'm doing wrong.....help! ---------------------------------------------------------------------- daveinhull · 2019-01-12 16:18 3 open and 3 closed; this was taken from the SQL statement in Access although I know it doesn't really need any parentheses. That's a bit like the old management training exercise about counting the F's ---------------------------------------------------------------------- sfeinst · 2019-01-12 16:25 Quote from: daveinhull on January 12, 2019, 03:22:55 pmHi, I think I'm going crazy! I have an SQL statement to a MS Access DB as follows Code: SQL  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i SELECT Table1.EntriesFROM Table1WHERE (((Table1.Entries)="Test1")); It works perfectly in Access, but in Pascal it returns a "Too few parameters. Expected 1. I just can't see what I'm doing wrong.....help! Try surrounding Test1 with single quotes instead of double quotes.  Double quotes is an Access specific variation to SQL.  Using Pascal means you are most likely using ODBC which would use standard SQL. ---------------------------------------------------------------------- daveinhull · 2019-01-12 18:58 Hi sfeinst, tries that, but just to double check tried again. This works Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i 'SELECT Entries FROM Table1' This doesn't Code: SQL  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i 'SELECT Entries FROM Table1 WHERE Entries = ''Test1''' Now comes up with Syntax error in FROM clause; Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Format ('SELECT Entries FROM Table1 WHERE Entries = %s',['Test1']) And this comes up with the too few parameters error; I've just got to be doing something silly, not unusual for me! ---------------------------------------------------------------------- daveinhull · 2019-01-14 11:26 Can anyone help? ---------------------------------------------------------------------- daveinhull · 2019-01-15 19:42 Hi, can anyone help with this problem as its stopped me continuing to develop my app. I just can't see what is wrong. Thanks ---------------------------------------------------------------------- korba812 · 2019-01-15 19:53 I think that the string value should be in quotes: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Format('SELECT Entries FROM Table1 WHERE Entries = ''%s''',['Test1']); ---------------------------------------------------------------------- guest63552 · 2019-01-15 20:12 Quote from: daveinhull on January 15, 2019, 08:42:04 pmHi, can anyone help with this problem as its stopped me continuing to develop my app. I just can't see what is wrong. I have used MS Access with Delphi last time more than 15 years ago. I can hardly remember, but double and single quote where differently meaning. I have used ADO component with Delphi, however I have no idea what is using with Lazarus.  Even worse, I do not use Windows anymore... However,  you can provide some very simple Lazarus source with test database, perhaps someone will help. However, I do not think that kind of SQL expression will be accepted from MS Access driver, I believe strings (and table names) need to be double quoted. If I can remember correctly, with ADO there was two separated methods: one was to provide clean string and execute commands only (UPDATE and similar), EXECUTE method or similar. Another was to use QUERY methods with SQL queries which returns data, as upper. ---------------------------------------------------------------------- madref · 2019-01-16 09:12 It's an easy fix. Use Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Chr(39) So: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i 'SELECT Entries FROM Table1 WHERE Entries = ' + chr(39) + 'Test1' + Chr(39) I had the sake problem with switching from Windows to Osx. Osx has NO MS Access so i had to write everything myself. I found this little program/app DB Browser for SQLite. In this app you can not only edit your database, but also make and test your SQL queries/views so you know if it's a valid one or a crap one ---------------------------------------------------------------------- daveinhull · 2019-01-16 22:51 Thanks everyone, now sorted. Turned out to be a combination of little mistakes, but the Chr(39) approach certainly stopped some confusion of double/triple '