>Hi everybody,
>
>I am wondering if you're using SqlCommandBuilder class and is there a way to get it generate normal UpdateCommand and not update command that even updates PK column and uses all columns in the where clause?
>
>I have this method at present
>
>
> protected Boolean ProcessDataTable(SqlCommand toSqlCommand, Boolean generateCommands = false)
> {
> Boolean results = false;
>
> try
> {
> this.table = new DataTable();
> this.adapter = new SqlDataAdapter(toSqlCommand);
> this.adapter.SelectCommand = toSqlCommand;
> this.adapter.Fill(this.table);
> if (generateCommands)
> {
> SqlCommandBuilder builder = new SqlCommandBuilder(adapter);
> adapter.UpdateCommand = builder.GetUpdateCommand(true);
> }
> results = true;
> }
> catch (Exception ex)
> {
> results = false;
> Logging.LogFormat(2, ex.Message); // at least log the problem
> }
>
> return results;
> }
>
>The idea is to simulate VFP TableUpdate, so I can set various columns values and then call a method that will automatically update my table. I got this suggestion in C# forum at MSDN, but the UpdateCommand generated is so ugly, that I am wondering if there can be any other approach.
>
>Thanks in advance.
So, no suggestions? Nobody uses the same approach?
Thanks in advance.
If it's not broken, fix it until it is.
My Blog