Hello to you X# community
Posted: Thu Dec 01, 2022 8:11 pm
Hello all,
Robert and Fabrice,
My name is Stacy Violett with Black Mountain Software. We are very excited to explore possibilities of using X# for a supported method of data access to foxpro data. I spoke with you and Fabrice at a Q&A session following your class at Visual Foxfest Session on Thursday, October 13th.
We are researching technology solutions for building a client facing restful API which will access foxpro free tables or vfp tables in a dbc.
To get started, we have some initial questions about how we might go about using X# for accomplishing our goal.
Our team worked through your wonderful example and got a working demo using Visual Studio 2022 to access local data.
- Hulst_FromFoxToNet.pdf - page 19
There are 2 initial questions we have.
**Item 1 ** - how can we build a reference to define a connection string to our remote data servers on the fly
- use an api or database we control which stores a data location of our choice based on parameters
example result - dbf://someserver.bmshelp.com:3099/D:data/folder/cetest/UB
This would be similar to our discussion about how Advantage Database Server can access data remotely.
We would prefer the access uses native X# data methods instead of Microsoft ODBC or OLEDB as we want the process of data access to be supported in X#. We need to be able to access a remote database of either free tables or tables in a Database Container
** Item 2 ** - what method and syntax is required to query remote data from Item 1 with fox type commands or sql commands and return the values in JSON
I have added notes into your document example from page 19 to try and describe our needs below:
Assume we have the following code in a project of type “Class Library”
As far as the C# app is concerned this is no different then a class developed with C#. When
you run this in the debugger you can also step through the code from C# to X# and back
again.
If you want to access data from a DBF file then this is also relatively easy. Add a new
method to the Customer class
The “Static” prefix tells the compiler that to use this method there is no need to instantiate
an object first. The Field command tells the compiler that FirstName and Lastname are
fields, so there is no ambiguity in the code.
To use this from C# you can call the method like this:
MessageBox.Show(Customer.GetNames());
Again, you can debug from C# into the X# code, see the customer table being opened and
traversed.
Thanks much for your help!
Stacy Violett
Robert and Fabrice,
My name is Stacy Violett with Black Mountain Software. We are very excited to explore possibilities of using X# for a supported method of data access to foxpro data. I spoke with you and Fabrice at a Q&A session following your class at Visual Foxfest Session on Thursday, October 13th.
We are researching technology solutions for building a client facing restful API which will access foxpro free tables or vfp tables in a dbc.
To get started, we have some initial questions about how we might go about using X# for accomplishing our goal.
Our team worked through your wonderful example and got a working demo using Visual Studio 2022 to access local data.
- Hulst_FromFoxToNet.pdf - page 19
There are 2 initial questions we have.
**Item 1 ** - how can we build a reference to define a connection string to our remote data servers on the fly
- use an api or database we control which stores a data location of our choice based on parameters
example result - dbf://someserver.bmshelp.com:3099/D:data/folder/cetest/UB
This would be similar to our discussion about how Advantage Database Server can access data remotely.
We would prefer the access uses native X# data methods instead of Microsoft ODBC or OLEDB as we want the process of data access to be supported in X#. We need to be able to access a remote database of either free tables or tables in a Database Container
** Item 2 ** - what method and syntax is required to query remote data from Item 1 with fox type commands or sql commands and return the values in JSON
I have added notes into your document example from page 19 to try and describe our needs below:
Assume we have the following code in a project of type “Class Library”
Code: Select all
Define Class Customer As Custom
LastName=””
FirstName=””
Procedure FullName_Access As String
Return This.FirstName+" "+This.LastName
End Define
This will create a normal .Net class that we can use from a C# project like this:
var customer = new Customer();
customer.LastName = "Doe";
customer.FirstName = "John";
MessageBox.Show(customer.FullName);
you run this in the debugger you can also step through the code from C# to X# and back
again.
If you want to access data from a DBF file then this is also relatively easy. Add a new
method to the Customer class
Code: Select all
Static Function GetNames As String
Local sb As StringBuilder
Field FirstName, LastName
** Item 1 ** get our connection string
** Set Default To c:VFF2022TestData **
** define our remote data connection string ** dbf://someserver.bmshelp.com:3099/D:asp/netdrive/cetest/UB
** Item 2 ** syntax/example for the connection itself
What syntax and methods are used to make the remote connection?
sb = StringBuilder{}
Use Customer
Go Top
Scan
Sb.AppendLine(Trim(FirstName)+" "+Trim(LastName))
End scan
Use
The “Static” prefix tells the compiler that to use this method there is no need to instantiate
an object first. The Field command tells the compiler that FirstName and Lastname are
fields, so there is no ambiguity in the code.
To use this from C# you can call the method like this:
MessageBox.Show(Customer.GetNames());
Again, you can debug from C# into the X# code, see the customer table being opened and
traversed.
Thanks much for your help!
Stacy Violett