Forum > Databases
Sanity Check Please on SQL Statement
daveinhull:
Hi,
I think I'm going crazy!
I have an SQL statement to a MS Access DB as follows
--- Code: SQL [+][-]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";}};} ---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:
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 :D
sfeinst:
--- Quote from: daveinhull on January 12, 2019, 03:22:55 pm ---Hi,
I think I'm going crazy!
I have an SQL statement to a MS Access DB as follows
--- Code: SQL [+][-]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";}};} ---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!
--- End quote ---
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:
Hi sfeinst, tries that, but just to double check tried again.
This works
--- Code: Text [+][-]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";}};} ---'SELECT Entries FROM Table1'
This doesn't
--- Code: SQL [+][-]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";}};} ---'SELECT Entries FROM Table1 WHERE Entries = ''Test1'''
Now comes up with Syntax error in FROM clause;
--- 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";}};} ---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:
Can anyone help?
Navigation
[0] Message Index
[#] Next page