try catch

 try
        {
            con.Open();
            added = cmd.ExecuteNonQuery();
            Label1.Text = "<b>操作提示:</b><br />";
            Label1.Text += added.ToString() + "条记录被添加成功。";
            Label1.Text += con.ServerVersion;
        }
        catch (Exception err)
        {
            Label1.Text = "<b>操作提示:</b><br />";
            Label1.Text += err.Message;
        }
        finally
        {
            con.Close();
            Label1.Text += "<b>操作提示:</b><br />";
            Label1.Text += con.State.ToString();
          

        }

posted @ 2010-08-09 11:34  midisong  阅读(140)  评论(0编辑  收藏  举报