DB error?

Trying to build a test DB and have run into a problem, it appears so simple but I don’t know what I’m doing wrong.

Code in Xojo:

db.SQLExecute s

When s=“create table vehicles
(name varchar NOT NULL PRIMARY KEY unique,
VT_version varchar”);"

That works, no error.

When s=“INSERT INTO vehicles VALUES (‘03MADP’,’01’);”

That does not work, get a db error,

Been working on this all morning and I don’t what I’m doing in error. Help would be appreciated.

Not at my computer at the moment, but maybe specify the fields? Like in

db.SQLExecute (“INSERT INTO Employees (Name,Job,YearJoined) VALUES (‘Dr.Strangelove’,‘Advisor’,1962)”)

[quote=151061:@Jim Smith]Trying to build a test DB and have run into a problem, it appears so simple but I don’t know what I’m doing wrong.

Code in Xojo:

db.SQLExecute s

When s=“create table vehicles
(name varchar NOT NULL PRIMARY KEY unique,
VT_version varchar”);"

That works, no error.

When s=“INSERT INTO vehicles VALUES (‘03MADP’,’01’);”

That does not work, get a db error,

Been working on this all morning and I don’t what I’m doing in error. Help would be appreciated.[/quote]

Shouldn’t it be like INSERT INTO vehicles (name,VT_version) VALUES (‘xyz’,‘xyz’). ?

Obviously we are between two Europa Cup fuball games in Germany, otherwise Jim might have gotten his replies sooner :wink:

I don’t understand, to me the following 2 statements look to have the same syntax(?)

INSERT INTO vehicles VALUES (‘xyz’,‘xyz’);
INSERT INTO vehicles VALUES (‘04MADP’,‘01’);
INSERT INTO vehicles VALUES (‘03MADP’,’01’);

The first gets no error, second gets no error, the third gets and error.

I think I see the problem. The quotes look different on the third line than the first and second.
Xojo’s unicode showes these quotes as 2019.

Anyhow, thanks guys.

Checking db.ErrorMessage is usually a good help in identifying what’s gone wrong.

[quote=151112:@Jim Smith]I don’t understand, to me the following 2 statements look to have the same syntax(?)

INSERT INTO vehicles VALUES (‘xyz’,‘xyz’);
INSERT INTO vehicles VALUES (‘04MADP’,‘01’);
INSERT INTO vehicles VALUES (‘03MADP’,’01’);

The first gets no error, second gets no error, the third gets and error.

I think I see the problem. The quotes look different on the third line than the first and second.
Xojo’s unicode showes these quotes as 2019.

Anyhow, thanks guys.[/quote]
The field names need to be specified as in the examples from Markus and Sascha, otherwise the database engine does not know where to put those values.

AND the 3rd Statement is not using ’ but ’

:wink:

Some of the English Premier League clubs field their B teams if they end up in the Europa League, it’s considered the lowest priority. Is it viewed the same way in Germany?

I preferred it when we had the European Cup and the Cup Winners Cup, at least I understood what each was for. The Europa League just seems to be something that exists for teams that aren’t quite good enough for the Champion’s League.

It should just be a straight knock-out competition.

But let’s not hijack the thread …

[quote=151142:@Markus Winter]But let’s not hijack the thread …[/quote]It’s OK, I think Jim’s problem is resolved :wink:

Careful if you’re on OS X and have Use Smart Quotes turned on in the global preferences

Try turning off Mavericks Preferences > Keyboard > Text > “Use smart quotes”
That + autocorrect have given me no end of grief in many apps

Thank you, thank you, thank you.

I knew it was something like that, I just did not know where to set it.

(Haven’t done that yet but I know that has to be it).

Thanks again.

Wow - I never knew that either.

On a few occasions I have spent HOURS looking at code which I knew was correct - only to find out later that a quote was ever so slightly different to all the others.

I even had to increase the code editor font size in order to notice it, because it was so small and unnoticeable.

Just turned off smart quotes and autocorrect. Hopefully that problem will now be a thing of the past.

Thank You Norman !

I didn’t know that. Thanks for the tip and the link.

You know the most difficult thing about my programming now is working alone.

Back when I worked, when I got stumped by a problem, like this one, I would set down with one of the other programmers in my group and talk it out. Most of the time the solution was self solved. It was just being able to say it out loud that worked.

I think one of the biggest asset Xojo has is this forum and the user who participate.

Thanks to each of you.