Client Interfaces Guide > Connecting to TDV Server through ADO.NET > Sample Code for Testing of an ADO.NET Driver > Using an Update Operation in the Sample Code
 
Using an Update Operation in the Sample Code
Update operations can perform insertions, updates, and deletions of data and rows. This example shows how to run update SQL. The most important method is ExecuteNonQuery. Usually it is used to execute update SQL. The return value is the number of rows that are affected by the update.
public void TestUpdate()
{
CompositeConnection conn = GetConnection();
try
{
CompositeCommand cmd = new CompositeCommand("delete from products where ProductID=1111", conn);
int cnt = cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
cmd.CommandText = "insert into products(ProductID,ProductName,ProductDescription) values(1111,'Composite DataBase','big base.')";
cnt = cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
cmd.CommandText = "update products set ProductName='TDV' where ProductID=1111";
cnt=cmd.ExecuteNonQuery();
cmd.CommandText = "select ProductName from products where ProductID=1111";
string name = (string)cmd.ExecuteScalar();
if (!name.Equals("TDV"))
Console.WriteLine("error occurred.");
}
catch (Exception ex)
{
throw ex;
}
}