This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Sync Editor: Configuring a MSSQL connector for 7.0.2, Update operation

Hi all,


I'm using Sync Editor to configure a connection between D1IM and MSSQL database, so far I don´t have a problem with Insert and Delete operations. I want to create, disable or modify SQL Users.

My problem is with the Update operation. For updates, I would like to do password update for SQL users.

My project is using C# script language. In my code, I'm using the following command:

sql.AppendFormat(store.Replace("ALTER LOGIN [%NAME%] WITH PASSWORD = '%PASSWORD%'", true));

I already configured:

- Mappings, Workflow and Start up Configuration

If I change the password for a specific user in D1IM, the update process is launched and that execute the Workflow for the SQL Update but the process stops on error.

After reviewed the logs, it complains about: "Unknown variable NAME"

name is a valid attribute in my SQL table and also is defined correctly in Mappings related to that workflow.

For testing purpose, using same user lets says name is UserA and password = pass12 and change name to be Usera and password = 12pass

That works ok, the workflow detected the change in name attribute and passed to the C# script. The process ends ok and the password was updated correctly. Please note that I did not change the name of the user in the database because my command only update the password for that user.

My question is: How can I force to pass as many variables as I need to the C# script? not only the ones that have been updated

Any idea? Am I missed something in my configuration?


Thanks in advanced.

Osvaldo

Parents
  • Hi Osvaldo,

    the store you are using only contains changed values. That's the reason why your replace throws the error.

    That's why you should normally use something like the following to avoid the error:

     if (store.Contains("NAME"))

    {

    ...

    }

    But as you have already figured out, that wouldn't help in your case.

    You should be able to use the following code to get access to the property NAME even if it hasn't changed, assuming that your name is always set to something.

    data.SystemObject.GetValue("NAME").ToString()

    Your code would then look like this:

     if (store.Contains("PASSWORD"))

    {

    sql.AppendFormat("ALTER LOGIN {0} WITH PASSWORD = '{1}'", data.SystemObject.GetValue("NAME").ToString(), store.GetValue<string>("PASSWORD", ""));

    }

    HtH

Reply
  • Hi Osvaldo,

    the store you are using only contains changed values. That's the reason why your replace throws the error.

    That's why you should normally use something like the following to avoid the error:

     if (store.Contains("NAME"))

    {

    ...

    }

    But as you have already figured out, that wouldn't help in your case.

    You should be able to use the following code to get access to the property NAME even if it hasn't changed, assuming that your name is always set to something.

    data.SystemObject.GetValue("NAME").ToString()

    Your code would then look like this:

     if (store.Contains("PASSWORD"))

    {

    sql.AppendFormat("ALTER LOGIN {0} WITH PASSWORD = '{1}'", data.SystemObject.GetValue("NAME").ToString(), store.GetValue<string>("PASSWORD", ""));

    }

    HtH

Children
No Data