Welcome, Guest
Username: Password: Remember me
This public forum is meant for questions and discussions about Visual FoxPro
  • Page:
  • 1

TOPIC:

SQLEXEC(), returning varchar fields as character. 19 Nov 2021 16:16 #20468

  • jawed4
  • jawed4's Avatar
  • Topic Author


  • Posts: 2
  • Hello Guys, Need Help.
    I am using VFP9 as front end for Sqlserver.
    For fetching data and updating I am using SQLEXEC(), but this returning character type of fields instead of varchar type field on backend.
    This resulting trailing spaces on backend table. Needing your help.
    Not interested in CursorAdapter or Vfp RemoteViews, is there any other way.
    Thanks a Lot.

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

    SQLEXEC(), returning varchar fields as character. 20 Nov 2021 03:37 #20471

    • kevclark64
    • kevclark64's Avatar


  • Posts: 126
  • I have only used SqlExec with Postgres, not with SQL Server. However, with postgres you set data options like that through the ODBC driver setup.

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

    SQLEXEC(), returning varchar fields as character. 20 Nov 2021 13:18 #20474

    • xinjie
    • xinjie's Avatar


  • Posts: 9
  • You only need to pay attention to the Format property of the control that binds the data source:F

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

    SQLEXEC(), returning varchar fields as character. 20 Nov 2021 16:07 #20475

    • jawed4
    • jawed4's Avatar
    • Topic Author


  • Posts: 2
  • Thanks XINJI, and XSHARP
    I tried format as F but this is not working.
    Then I found this paragraph by googling and this command is working.
    I found the following paragraph
    A better solution
    VFP 9.0 offers a much better solution. Unlike earlier releases, version 9.0 supports the varchar data type in remote views. If both the RV and back-end fields are varchars, the data will not be padded with spaces, so the problem won't arise.
    However, this does not happen automatically. By default, any varchar columns on the back-end will still be mapped to character fields in the view, as in earlier versions. To get the benefits of varchars, you have to explicitly change the data type in the view.
    If you are starting a new application and you haven't yet created your remote views, you're in luck. All you have to do is to execute the following command before you create the views:
    CURSORSETPROP("MapVarchar", .T., 0)
    This tells VFP to map varchars in the view to varchars on the back-end. By passing 0 as the third parameter, you stipulate that this setting will apply to all views created in the session. This only affects new views that you create; any existing views are unaffected. The setting is not persistent, so be sure to execute the above command before you create any views in the current session.

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

    • Page:
    • 1