Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SqlCommandBuilder class
Message
 
 
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01598513
Message ID:
01598540
Vues:
47
>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform