Page 1 of 1

Security Token in Salesforce connectionstring

Posted: Mon 19 Nov 2018 08:33
by nbcol
Hello,
I'm using the Salesforce dotconnect version 5.0.2045.0.
I would like to provide the connectionstring via the constructor of Dbcontext. I tried the following value:
User Id=userid;Password=password;Security Token=securitytoken;Persist Security Info=True;Host=test.salesforce.com

I receive the following error:
Keyword not supported: 'security token'.

I then tried the SalesforceConnectionStringBuilder class:
Devart.Data.Salesforce.SalesforceConnectionStringBuilder sfCSB = new

Code: Select all

Devart.Data.Salesforce.SalesforceConnectionStringBuilder();
sfCSB.Host = "test.salesforce.com";
sfCSB.UserId = "userid";
sfCSB.Password = "password";
sfCSB.SecurityToken = "securitytoken";
sfCSB.MaxPoolSize = 150;
sfCSB.ConnectionTimeout = 30;
And used the connectionstring as generated by the class:

Code: Select all

sfCSB.ConnectionString
And I get the same error message.

Can you please provide me with the format I need to use for the connection string?

Thank you

Re: Security Token in Salesforce connectionstring

Posted: Mon 19 Nov 2018 19:43
by Shalex
You are using XML mapping, aren't you? Please try this code:

Code: Select all

        var sfCSB = new Devart.Data.Salesforce.SalesforceConnectionStringBuilder();
        sfCSB.Host = "test.salesforce.com";
        sfCSB.UserId = "userid";
        sfCSB.Password = "password";
        sfCSB.SecurityToken = "securitytoken";
        sfCSB.MaxPoolSize = 150;
        sfCSB.ConnectionTimeout = 30;

        EntityConnectionStringBuilder entityBuilder = new EntityConnectionStringBuilder();
        entityBuilder.Provider = "Devart.Data.Salesforce";
        entityBuilder.ProviderConnectionString = sfCSB.ConnectionString;

        entityBuilder.Metadata = @"res://*/YourModel.csdl|res://*/YourModel.ssdl|res://*/YourModel.msl";

        using (Entities context = new Entities(entityBuilder.ToString())) {
            var a = context.MyEntity.First();
        }

Re: Security Token in Salesforce connectionstring

Posted: Mon 26 Nov 2018 16:46
by nbcol
Hello,

I have tried the solution and it works well. Thank you!

ps is it possible to mark a question as done?

Re: Security Token in Salesforce connectionstring

Posted: Tue 27 Nov 2018 10:34
by Shalex
nbcol wrote: Mon 26 Nov 2018 16:46is it possible to mark a question as done?
There is no way to mark a question as done.

Thank you for the confirmation that the issue is solved.