FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour A sample FWH-XHARBOUR-MYSQL?
Posts: 2170
Joined: Fri Jul 18, 2008 01:24 AM
A sample FWH-XHARBOUR-MYSQL?
Posted: Mon Apr 09, 2012 09:59 PM

Dear friends:
Can somebody post a small sample about how use fields names on variables?
Something like this:

cField := "FIELD1"

oServer:Query("INSERT INTO MyTable ( '"+ cField + "') VALUES ('"+ cField + "' + '100.00') ,")

I got: Sintaxis error near FIELD1.

Thanks in advance.

Francisco J. Alegría P.

Chinandega, Nicaragua.



Fwxh-MySql-TMySql
Posts: 368
Joined: Sun May 31, 2009 06:25 PM
Re: A sample FWH-XHARBOUR-MYSQL?
Posted: Tue Apr 10, 2012 12:19 AM
Hi Francisco,

I do not understand the use of cField in the final part of your query if you want to insert a row (append). Try:
Code (fw): Select all Collapse
Query("INSERT INTO MyTable (" + cField + ") VALUES ('100.00')")
Regards,



André Dutheil

FWH 13.04 + HB 3.2 + MSVS 10
Posts: 2170
Joined: Fri Jul 18, 2008 01:24 AM
Re: A sample FWH-XHARBOUR-MYSQL?
Posted: Tue Apr 10, 2012 01:55 AM
Hi, ADutheil . Thanks for your reply.
Yes, your are right.
Code (fw): Select all Collapse
Query("INSERT INTO MyTable (" + cField + ") VALUES ('100.00')")

But the error still showing. MySQL recognizes the value of the variable, but always shows the syntax error.
For example, SQLyog gives the same error in this sample;
Code (fw): Select all Collapse
SET @c = 'FIELD1';
INSERT INTO mitable (@c) VALUES ('100.00') ;

Is there other idea?
Francisco J. Alegría P.

Chinandega, Nicaragua.



Fwxh-MySql-TMySql
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: A sample FWH-XHARBOUR-MYSQL?
Posted: Tue Apr 10, 2012 07:10 AM
Try

Code (fw): Select all Collapse
Query("INSERT INTO MyTable (" + cField + ") VALUES (100.00)")


EMG
Posts: 2170
Joined: Fri Jul 18, 2008 01:24 AM
Re: A sample FWH-XHARBOUR-MYSQL?
Posted: Tue Apr 10, 2012 01:46 PM

Enrico, your are great...!!!

It's working!
I had tried a thousand ways and never occurred to me to enter the numeric value without quotes.
Thank you very much.

Best regards

Francisco J. Alegría P.

Chinandega, Nicaragua.



Fwxh-MySql-TMySql

Continue the discussion