1. Ramón San Félix Ramón
  2. SnapDevelop
  3. Tuesday, 21 July 2020 06:54 AM UTC
Hello, in my PowerBUilder application I use Sql Native Client to connect to Microsoft SQL Server.

I use this Parameters: SQLCA.DBMS = "SNC SQL Native Client (OLE DB)" SQLCA.LogPass = "serverpassword" SQLCA.ServerName = "server\instance" SQLCA.LogId = "id" SQLCA.AutoCommit = False SQLCA.DBParm = "Database = 'databasename', TrimSpaces = 1, DateFormat = '\' 'dd-mm-yyyy \' '', DateTimeFormat = '\' 'dd-mm-yyyy hh: mm: ss \' ' '" The question is how to enter these parameters in the SnapDvelop connection string.
I'm interested in the Trim Sapaces parameter.

In SnapDelop I have this p
arameters:
 "Local": "Data Source=server\\instanece;Initial Catalog=databasename;Integrated Security=False;User ID=id;Password=serverpassword;Pooling=True;Min Pool Size=0;Max Pool Size=100;ApplicationIntent=ReadWrite"
Accepted Answer
Logan Liu @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 21 July 2020 10:31 AM UTC
  2. SnapDevelop
  3. # Permalink

Hi Ramón,

TrimSpaces is an option from PB but not supported by the standard SQL Server connection string.

Please make sure you are using SnapObjects.Data 2.1.0 and corresponding database provider. Then refer to the following code about how to set the TrimSpaces option in the StartUp.cs file:

public class StartUp
    {
        public void ConfigureServices(IServiceCollection services)
        {         
            // UseSqlServer with connection string and other options.
            services.AddDataContext<SqlServerContext>(m => m.UseSqlServer(CONNECTION_STRING, n => n.TrimSpaces = true));
        }
    }

 

BTW: after getting the next release (PB 2019 R2 MR), you will be able to set the TrimSpaces option when creating a DataContext in SnapDevelop. SnapDevelop will help you to generate additional settings in your appsettings.json file. Then you can simplify the code:

    public class StartUp
    {
        public void ConfigureServices(IServiceCollection services)
        {
            // UseSqlServer with the IConfiguration object and the key specified in the connection strings.
            services.AddDataContext<SqlServerContext>(m => m.UseSqlServer(this.Configuration, "MyConnectionString"));

        }

Regards,

Logan

 

Comment
There are no comments made yet.
Ramón San Félix Ramón Accepted Answer Pending Moderation
  1. Tuesday, 18 August 2020 17:45 PM UTC
  2. SnapDevelop
  3. # 1

Hi, I have tried the first option and it works correctly.

And now I have also been able to successfully test the second option ...

I have an example from Dora Sistemas (Appeon Partner in Mexico) that goes with JWT Authentication and Roles.

In this example they dynamically create the connection and I cannot understand how I can add the parameter trimspace = yes or how can I make it read the dbparm from the appsettings.json

I attach an example, It is not exactly the example of Dora because I have been making some changes to see how it goes ...

Attachments (1)
Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.