Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SQLRDD novice

229 views
Skip to first unread message

David H

unread,
Apr 30, 2013, 10:01:05 AM4/30/13
to
Hello,

I have just started trying to use SQLRDD to connect to our MS SQL server. I have been trying to connect to one of the existing SQL tables and keep getting errors.
This is the sample code I am trying to run.

#include "sqlrdd.ch"

REQUEST SQLRDD
REQUEST SR_ODBC


PROCEDURE Main()
local cDns := "Driver=SQL Server;DATABASE=UPS;TRUSTED_CONNECTION=Yes;SERVER=devSQL;Description=XHtoSQL;APP=XHtoSQL"
local cActconn := 0
local cComm := ""
local nErr, nPos
local apCode, oSql
local aTables := {}

RddsetDefault("SQLRDD")

SR_AddConnection(CONNECT_ODBC_QUERY_ONLY,cDns)
oSql := SR_GetActiveConnection()

? oSQL

? "Connected to :", SR_GetConnectionInfo(, SQL_DBMS_NAME ), "- Version :", SR_GETCONNECTIONInfo(,SQL_DBMS_VER )
? SR_ExistTable( "UPSCI" )
? SR_Version()
oSQL:exec("select top 2 * from UPSCI",,.f.)


When the exec line runs it produces the error:

Error BASE/1004 Class: 'NUMERIC' has no exported method:
EXEC Arguments: ( [1] = Type: N Val: 1 [2] = Type: C Val: select top 2 8 from UPSCI [3] = Type: U [4] = Type: L Val: .F.)

I could use help determining what I am doing wrong.

Thanks

Ella

unread,
Apr 30, 2013, 10:38:29 AM4/30/13
to
Hello,

> I have just started trying to use SQLRDD to connect to our MS SQL server. I >

Please supply the exact version of MS SQL server you are using, as well as the client you have installed.


>
> oSQL:exec("select top 2 * from UPSCI",,.f.)
>
> When the exec line runs it produces the error:
>
> Error BASE/1004 Class: 'NUMERIC' has no exported method:
>
> EXEC Arguments: ( [1] = Type: N Val: 1 [2] = Type: C Val: select top 2 8 from UPSCI [3] = Type: U [4] = Type: L Val: .F.)

It looks like an ODBC problem, not specifically related to SQLRDD.
Please try alternatives like:

select * from mytable limit 2
or
select myfield1, myfield2,... from mytable limit2

cul...@gmail.com

unread,
Apr 30, 2013, 11:43:34 AM4/30/13
to
Hi

Your error is here
oSql := SR_GetActiveConnection() // this return the current connection number

to get the currect connection object use
osql:=sr_getconnection()


Second
oSQL:exec("select top 2 * from UPSCI",,.f.) query where the result is to be put?

for temporary table use
oSQL:exec("select top 2 * from UPSCI",,.t.,,"test.dbf",'test')

for dbf in memory
use ("select top 2 * from UPSCI" new alias temp via "SQLRDD"

into an array
aRet :={}
oSQL:exec("select top 2 * from UPSCI",,.t.,@aret)

Regards
Luiz

David H

unread,
Apr 30, 2013, 12:56:59 PM4/30/13
to
On Tuesday, April 30, 2013 10:38:29 AM UTC-4, Ella wrote:
> Hello,
>
>
>
> > I have just started trying to use SQLRDD to connect to our MS SQL server. I >
>
>
>
> Please supply the exact version of MS SQL server you are using, as well as the client you have installed.

We are using MS SQL Server Version 11.00.3000.
>
>
>
>
>
> >
>
> > oSQL:exec("select top 2 * from UPSCI",,.f.)
>
> >
>
> > When the exec line runs it produces the error:
>
> >
>
> > Error BASE/1004 Class: 'NUMERIC' has no exported method:
>
> >
>
> > EXEC Arguments: ( [1] = Type: N Val: 1 [2] = Type: C Val: select top 2 8 from UPSCI [3] = Type: U [4] = Type: L Val: .F.)
>
>
>
> It looks like an ODBC problem, not specifically related to SQLRDD.
>
> Please try alternatives like:
>
>
>
> select * from mytable limit 2
>
> or
>
> select myfield1, myfield2,... from mytable limit2

Thank You for you quick reply and suggestions. I will try theses.

David H

unread,
Apr 30, 2013, 2:35:07 PM4/30/13
to
On Tuesday, April 30, 2013 11:43:34 AM UTC-4, cul...@gmail.com wrote:
> Hi
>
>
>
> Your error is here
>
> oSql := SR_GetActiveConnection() // this return the current connection number
>
>
>
> to get the currect connection object use
>
> osql:=sr_getconnection()
>
>
>
>
>
> Second
>
> oSQL:exec("select top 2 * from UPSCI",,.f.) query where the result is to be put?
>
>
>
> for temporary table use
>
> oSQL:exec("select top 2 * from UPSCI",,.t.,,"test.dbf",'test')
>
>
>
> for dbf in memory
>
> use ("select top 2 * from UPSCI" new alias temp via "SQLRDD"
>
>
>
> into an array
>
> aRet :={}
>
> oSQL:exec("select top 2 * from UPSCI",,.t.,@aret)
>
>
>
> Regards
>
> Luiz
>
>
>
> Em terça-feira, 30 de abril de 2013 11h01min05s UTC-3, David H escreveu:
>

Thank you for your quick reply Luiz. I changed the line to oSQL := sr_getconnection and that solved the biggest problem.

I did get a DBCREATE error when it tried to create the test.dbf table but returning the data to an array works great.
0 new messages