Page 1 of 1

Spot my error

Posted: Saturday 5th November 2022 6:08pm
by AndyGable
Hi Everyone

I hope someone can spot my error as I can not and this is driving me nuts

Code: Select all

    $Query &= "Select "
    $Query &= "function, "
    $Query &= "linenumber,  "
    $Query &= "lineaglinment, "
    $Query &= "linefont, "
    $Query &= "Replace(linetext, ",, ", ", ") As Linetext "
    $Query &= "from rec_table "
    $Query &= "Where function='" & RecipitMode & "' order by linenumber ASC;"
The above SQL code works on Windows VB.net but I can not seem to get it to work correct on Gambas could someone Please point out where i have gone wrong (as I have been working on this all day)

Thank-you

Re: Spot my error

Posted: Saturday 5th November 2022 6:49pm
by BruceSteers
i do not know SQL but this line is wrong...

$Query &= "Replace(linetext, ",, ", ", ") As Linetext "

the Replace is a vb command not a sql one

maybe...

$Query &= Replace(linetext, ",, ", ", ")

(just a guess, it's something like that)

Re: Spot my error

Posted: Saturday 5th November 2022 6:51pm
by BruceSteers
BruceSteers wrote: Saturday 5th November 2022 6:49pm i do not know SQL but this line is wrong...

$Query &= "Replace(linetext, ",, ", ", ") As Linetext "

the Replace is a vb command not a sql one

maybe...

$Query &= Replace(linetext, ",, ", ", ")

(just a guess, it's something like that)
i could be wrong and it is sql command in which case ...
$Query &= "Replace(linetext, \",, \", \", \") As Linetext "

(backslash the quotes)

Like i say i do not know sql but understanding what that line is supposed to do and doing it the gambas way is the key to fixing the problem.

Re: Spot my error

Posted: Saturday 5th November 2022 7:53pm
by grayghost4
this might help you ;

viewtopic.php?t=1336

Re: Spot my error

Posted: Saturday 5th November 2022 11:25pm
by AndyGable
Thanks Guys I shall have a read of that other forum tomorrow morning.

Re: Spot my error

Posted: Sunday 6th November 2022 4:58pm
by grayghost4
 "\"" & sVariableName & "\"" 
this is the same this :
 Quote(sVariableName)
When building a string to query a SQL file and a little eraser to write :D

Re: Spot my error

Posted: Monday 7th November 2022 8:45pm
by sadams54
I do alot of mysql with gambas. I would have to agree that we need some more information. If you can show us what the data in the table looks like along with what VB.net is returning then what you get on gambas I think I can help you.

Re: Spot my error

Posted: Tuesday 8th November 2022 12:06am
by thatbruce
I suggest that you look at the gb.db.SQLRequest class if you have a lot of these to do.
It takes a bit of getting used to but in the end it makes building sql statements quite easy.
b

Re: Spot my error

Posted: Tuesday 8th November 2022 3:12am
by grayghost4
Are there any examples of how to use it .... sample programs ?