Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

X# Core - How to send query to Sql Server, get a cursor or table? 10 Mar 2019 20:15 #7634

  • FoxProMatt
  • FoxProMatt's Avatar
  • Topic Author



I'm exploring X# Core as total newbie... Learning a little more by the hour. I am only interested in Core stuff at this point, and have no experience or need of VO related paths.

So, my next step of eye-opening experience in X# would be if I could send a SQL query to my Sql Server instance, and get a cursor (or "table" or "data table" or whatever is it called). Then I want to display those rows in a grid on a WinForm.

So, would I be doing this with X# Core commands/objects, or would it be .Net DataSets and DataTables from ADO.net?

Does Entity Framework 6 from .Net have a place in this X# world? I already know Entity Framework.

I presently hist my Sql Server from FoxPro using SqlExec() command and get back a native FoxPro cursor. I'm trying to find parallel workflows in X# Core or else someone get me going in the right paradigm shift I need to make for X#.

Please Log in or Create an account to join the conversation.

X# Core - How to send query to Sql Server, get a cursor or table? 10 Mar 2019 21:14 #7635

  • lumberjack
  • lumberjack's Avatar


  • Posts: 714
  • mattslay wrote: I'm exploring X# Core as total newbie... only interested in Core stuff at this point

    So, my next step of eye-opening experience in X# would be if I could send a SQL query to my Sql Server instance, and get a cursor (or "table" or "data table" or whatever is it called). Then I want to display those rows in a grid on a WinForm.

    Yes, with Core you would do it the way you do it in c#. Pseudo-code:
    FUNCTION Start() AS VOID
      LOCAL oForm AS MyForm
      oForm := MyForm{}
      Application.Run(oForm)
    RETURN
    CLASS MyForm INHERIT Form
      CONSTRUCTOR()
        SUPER() // base() in c#
        SELF:InitializeForm()
      RETURN
      METHOD InitializeForm() AS VOID
        VAR oConn := SqlServerConnection{<InitParameters>}
        VAR oComm := SqlServerCommand{<InitParameters>}
        oComm:CommandText := "select * from mytable where..."
        oComm:Connection:Open()
        VAR rdr := oComm:ExecuteReader()
        WHILE rdr:Read()
    
        ENDDO
        VAR oGrid := DataGridView{}
        oGrid:DockStyle := DockStyle.Fill
        SELF:SuspendLayout()
        SELF:Controls:Add(oGrid)
        ....
       SELF:ResumeLayout()
       // Bind your grid to the rdr etc.
      RETURN
    END CLASS

    So, would I be doing this with X# Core commands/objects, or would it be .Net DataSets and DataTables from ADO.net?

    Indeed it would be a true .NET way of doing things DbProviderFactory, DbConnection, DbCommand and datasets and datatables..

    Does Entity Framework 6 from .Net have a place in this X# world? I already know Entity Framework.

    Remember I told you before X# is c# in XBase syntax. If you use ILSpy with the XSharp.Language plug-in, you should be able to view a c# EF assembly decompiled in X#.

    I presently hist my Sql Server from FoxPro using SqlExec() command and get back a native FoxPro cursor. I'm trying to find parallel workflows in X# Core or else someone get me going in the right paradigm shift I need to make for X#.

    There is a SQLSelect, just search for it in the X# helpfile. It does have a link to the git from the helpfile... Look at the constructor. Although I would go the .NET ADO way.
    ______________________
    Johan Nel
    George, South Africa

    Please Log in or Create an account to join the conversation.

    X# Core - How to send query to Sql Server, get a cursor or table? 11 Mar 2019 06:09 #7641

    • wriedmann
    • wriedmann's Avatar


  • Posts: 3198
  • Hi Matt,

    let me add something: as Johan wrote: X# is in its heart a C# compiler with Xbase syntax (and a lot of language extensions like codeblocks, dynamic arrays and some more).
    Therefore you can use all the libraries that are available to C# and VB.NET including ADO.NET and Entity Framework.
    Since X# comes from VO, it offers also the VO way to access data: DBServers and the VO SQL Classes complete with VO windows and the relative name based databinding.
    And hopefully sometimes (with help from the VFP community) it will also contain the data classes from VFP complete with their window classes.
    So, the best way for you may be to use the Entity Framework or the ADO.NET classes.
    Wolfgang
    P.S. in my new applications I use ADO.NET because I need to address several backends: Oracle, SQL Server, Firebird, SQLite, PostgreSQL, MySQL and Access.
    Wolfgang
    Wolfgang Riedmann
    Meran, South Tyrol, Italy

    www.riedmann.it - docs.xsharp.it

    Please Log in or Create an account to join the conversation.

    • Page:
    • 1