I am a newbie from switching from DBFCDX to AXSQLCDX. I just found this thread which offers another promissing approach for using sql with ads in x#.
What are your opinions about the two approaches?
..I use AXSQLCDX and Selects with parameters only with VO at the moment and it's working fine.
In VO the last parameter of AdsConnect60(..) is 'by Ref' - so you have to use ...., @hConnect ) to get the connection handle.
To work always with the correct table, I use the fieldnames with it's tablename:
oServer := AdsSQLServer{ "SELECT * FROM DMODELL WHERE DMODELL.MONUMMER = ?", , , "AXSQLCDX", , {{ 1, "00010225" }}}
// VO dialect
FUNCTION Start( ) AS VOID
LOCAL p AS IntPtr
? p // 0x00000000
GetIntPtr ( p )
? p // 0x00000400
?
p := IntPtr { 0 }
? p // 0x00000000
GetIntPtr ( OUT p )
? p // 0x00000400
?
p := IntPtr { 0 }
? p // 0x00000000
GetIntPtr ( REF p )
? p // 0x00000400
/*
?
p := IntPtr { 0 }
? p // 0x00000000
GetIntPtr ( @p ) // to compile this the Vo7 switch must be enabled
? p // 0x00000400
*/
RETURN
FUNCTION GetIntPtr ( phConnect OUT IntPtr ) AS VOID
// Deactive the phConnect assignment and you ll see the expected compile error:
// XS0177: The OUT parameter 'phConnect ' must be assigned to before control leaves the current method
// ? phConnect == NULL // true
phConnect := IntPtr { 1024 }
// ? phConnect == NULL // false
RETURN
FYI: Don't know if someone is using the parameterized approach of AdsSQLServer, but it is not working. I receive a 7200 ADS Error, so something with the query is supposedly wrong. But the query works fine in ADS Query Editor. Now I use this as a workaround:
METHOD Init( oFile, lShareMode, lReadOnlyMode, xDriver, aRdd ) CLASS AdsSQLServer
One of the reasons I had a 7200 once was that I passed a path without :, like dMydirMyDBFFile. Second reason I had once is by using these quots ``, normal in MySQL, which ADS doesn't like.
thanks. Maybe this is not supported by X# RDD? I was mixing up ADS and X# Userguides. Here is a call to ADSSqlServer with Parameters: Link and here I cannot find a sixth parameter in the X# CTOR Link
If it's simply not supported and not my fault, than the workaround is fine for me.
We have derived our X# ADS support from the Vulcan support for ADS.
I see now that SAP did not add the extra parameter for ADSSqlServer to the Vulcan code.
I can add that to X#. Do you have a complete example so I can test it ?
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
Does anyone know where I can find a working example of approaching a DBF with SQL commands, using ADS? I have it working in VO but can't get the code to work in X#. The ultimate goal is to be able to use a DBF as datasource for a Winforms datagridview so any comments on that are also very welcome.