Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ODBC connection
Message
From
22/11/2007 08:26:46
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
22/11/2007 07:05:19
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Database:
MySQL
Miscellaneous
Thread ID:
01270657
Message ID:
01270666
Views:
22
>Hello Everybody,
>
>I am trying to retrieve data from MySQL database. I was using the following method till now.
>1. Create a user DSN ('mySqlODBC')
>2. lha = sqlConnect('mySqlODBC')
>3. lcQry = "Select u.userid Id, concat(u.firstname, ' ', u.lastname) Name, from loans as l "
>4. lnResult = SQLEXEC(lha, lcQry, 'cmpData')
>5. SELECT cmpData
>
>I was trying to get rid of the process to create user DSN, hence tried the following
>1. mySQLCn = "driver=MySQL ODBC 3.51 Driver;server=192.168.2.2;uid=####;pwd=##"
>2. lha = SQLSTRINGCONNECT(mySQLCn,.T.)
>3. lcQry = "Select u.userid Id, concat(u.firstname, ' ', u.lastname) Name, from loans as l "
>4. lnResult = SQLEXEC(lha, lcQry, 'cmpData')
>5. SELECT cmpData
>However now I get the error "cursor cmpData not found". It looks like that SQLEXEC is failing.
>
>Is there anything wrong I am doing ? Kindly suggest.
>
>Many thanks in advance,
>Abhi

Instead of
Select u.userid Id, concat(u.firstname, ' ', u.lastname) Name, from loans as l
why don't you use the alias you specified
Select l.userid Id, concat(l.firstname, ' ', l.lastname) Name from loans as l
or specify the alias you really use:
Select u.userid Id, concat(u.firstname, ' ', u.lastname) Name from loans as u
Also note that you had a "name, from" - can't have a comma after the last field. MySql's parser would expect another field, take the word "from" to be it, and then wouldn't know what to do with "loans" because it's not a keyword.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform