code_junkie

How would you get the Sql Command objects for a Given TableAdaptor and SqlDataAdaptor in C# (.NET 2.0)

Nov 11th, 2011
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. SqlDataAdapter da = new SqlDataAdapter();
  2. var cmd1 = ((IDbDataAdapter)da).DeleteCommand;
  3. var cmd2 = ((IDbDataAdapter)da).UpdateCommand;
  4. var cmd3 = ((IDbDataAdapter)da).SelectCommand;
  5. var cmd4 = ((IDbDataAdapter)da).InsertCommand;
  6.  
  7. if (SqlCommandObj.GetType().Name.Contains("TableAdapter"))
  8. {
  9. sqlCmdInsert = (SqlCommand)(SqlCommandObj.GetType().GetField("InsertCommand").GetValue(SqlCommandObj));
  10. }
Add Comment
Please, Sign In to add comment