public void UpdateContactTableByDataSet(DataSet ds
{
try
{
SqlDataAdapter myAdapter = new SqlDataAdapter();
SqlConnection conn = new SqlConnection(strConnection);
SqlCommand myCommand = new SqlCommand(
myAdapter
SqlCommandBuilder myCommandBuilder = new SqlCommandBuilder(myAdapter);
conn
SqlTransaction myTrans = conn
myCommand
try
{
myAdapter
myTrans
}
catch(Exception e)
{
try
{
myTrans
}
catch (SqlException ex)
{
if (myTrans
{
Console
}
}
}
finally
{
conn
}
}
catch(Exception ex)
{
throw ex;
}
}
From:http://tw.wingwit.com/Article/program/net/201311/15608.html