>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.