Hello,
I have a problem with SQL Connections.
When I build a SQL Connection with all parameters, how can initalize Visual Cron to build the ConnectionString from my parameters?
Here is my Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VisualCronAPI;
using VisualCron;
namespace vc1
{
class Create_Connections_SQL
{
Server server;
VCDS vcds;
public Create_Connections_SQL(VCDS vcds)
{
this.server = vcds.server;
this.vcds = vcds;
}
public VCDS create()
{
mssql(name: "test123", instanz: @"ServerXYZ,Port123", db: "test");
return vcds;
}
void mssql(String name, String instanz, String db )
{
ConnectionClass co = new ConnectionClass();
co.Name = name;
co.ProtocolType = ConnectionClass.ProtocolT.SQL;
co.SecurityMode = ConnectionClass.SecurityModeT.Implicit;
co.SQLConnection.DataBaseType = SQLConnectionClass.DatabaseT.MSSQL;
co.SQLConnection.StorageType = SQLConnectionClass.StorageT.Database;
co.SQLConnection.DataProvider = SQLConnectionClass.DataProviderT.DirectMSSQL;
co.SQLConnection.ConnectionTypeId = 34;
co.SQLConnection.WizardId = 1;
SQLConnectionParameterClass p1 = new SQLConnectionParameterClass();
p1.ParameterName = "Server";
p1.ParameterValue = server.Encrypt(instanz);
co.SQLConnection.ConnectionParameters.Add(p1);
SQLConnectionParameterClass p2 = new SQLConnectionParameterClass();
p2.ParameterName = "Database";
p2.ParameterValue = server.Encrypt(db);
co.SQLConnection.ConnectionParameters.Add(p2);
SQLConnectionParameterClass p3 = new SQLConnectionParameterClass();
p3.ParameterName = "Trusted_Connection";
p3.ParameterValue = server.Encrypt("true");
co.SQLConnection.ConnectionParameters.Add(p3);
server.Connections.Add(co );
vcds.theconns.Add(name, co);
}
}
}