X-Sharp / XSharpPublic

Public repository for the source code for the XSharp Compiler, Runtime, Project System and Tools.
Apache License 2.0
113 stars 38 forks source link

[VFP]Two problems with CursorAdapter.SelectCmd in the XSharp.VFP namespace #1559

Open vfp9 opened 1 month ago

vfp9 commented 1 month ago

X# Version : 2.20.0.3

  1. You can't use ? in a Select statement. to pass parameters.For example:

    CursorAdapter.SelectCmd = "Select ID, Name From Demo Where ID = ?VariableName "

    "VariableName" is the name of a variable that has been defined and assigned a value or the name of a field in an opened table(It may be a table.field ). Build and run without errors. CursorFill() returns the False.

  2. You can't use double quote in a Select statement to pass parameters.For example:

    CursorAdapter.SelectCmd = [Select ID, Name From Demo Where ID = "ID001" ]

    Build and run without errors. CursorFill() returns the False. CursorFill() returns the True If you replace double quotes with single quotes.

The described above is allowed in VFP.

vfp9 commented 1 month ago

In addition, after I successfully CursorFill() in the Form1_Load method, it seems that the opened cursor is automatically closed after the WinForm is rendered. I'm not sure if it's my usage or a bug in the CursorAdapter.

vfp9 commented 1 month ago

For a separate SQL-Select command, SQLExec() also fails to execute in both of these cases.

RobertvanderHulst commented 1 month ago

Xinjie, Is "Variablename" the name of a local variable or of a public / private? What are the compiler options in the project?

vfp9 commented 1 month ago

Robert

"Variablename",As I personally understand it, it can be any kind of variable.(According to VFP, it can be Public/Local/private,Any variable that is visible to the current Select statement will work.)

The following compiler options are stored in the xsproj file:

<Dialect>FoxPro</Dialect>
<Allowdot>True</Allowdot>
<NamedArgs>True</NamedArgs>
<OutputName>DisplayRelations</OutputName>
<StartupObject />
<AllowOldStyleAssignments>True</AllowOldStyleAssignments>
<LB>True</LB>
<Unsafe>False</Unsafe>
<InitLocals>True</InitLocals>
<MemVar>True</MemVar>
<Undeclared>True</Undeclared>
<Fox2>True</Fox2>
<Fox1>False</Fox1>
<AZ>False</AZ>

Note that the results of the program seem to be independent of compiler options.