Spot my error

Post your Gambas programming questions here.
Post Reply
AndyGable
Posts: 359
Joined: Wednesday 2nd December 2020 12:11am
Location: Northampton, England
Contact:

Spot my error

Post 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
User avatar
BruceSteers
Posts: 1521
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Spot my error

Post 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)
If at first you don't succeed , try doing something differently.
BruceS
User avatar
BruceSteers
Posts: 1521
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Spot my error

Post 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.
If at first you don't succeed , try doing something differently.
BruceS
User avatar
grayghost4
Posts: 174
Joined: Wednesday 5th December 2018 5:00am
Location: Marengo, Illinois usa

Re: Spot my error

Post by grayghost4 »

this might help you ;

viewtopic.php?t=1336
AndyGable
Posts: 359
Joined: Wednesday 2nd December 2020 12:11am
Location: Northampton, England
Contact:

Re: Spot my error

Post by AndyGable »

Thanks Guys I shall have a read of that other forum tomorrow morning.
User avatar
grayghost4
Posts: 174
Joined: Wednesday 5th December 2018 5:00am
Location: Marengo, Illinois usa

Re: Spot my error

Post 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
User avatar
sadams54
Posts: 139
Joined: Monday 9th July 2018 3:43am
Contact:

Re: Spot my error

Post 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.
User avatar
thatbruce
Posts: 161
Joined: Saturday 4th September 2021 11:29pm

Re: Spot my error

Post 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
Have you ever noticed that software is never advertised using the adjective "spreadable".
User avatar
grayghost4
Posts: 174
Joined: Wednesday 5th December 2018 5:00am
Location: Marengo, Illinois usa

Re: Spot my error

Post by grayghost4 »

Are there any examples of how to use it .... sample programs ?
Post Reply