蜗牛,在赛跑

--努力去改变吧
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

.net在线更新SQL数据库

Posted on 2007-12-13 14:22  body  阅读(293)  评论(0)    收藏  举报
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString);
        //string sql = "Create   Table   testtable(test1   varchar   not   null   primary   key,test2   int)";
        string sql = "alter   table   test   add   test5 int default (0)";
        SqlCommand cmd = new SqlCommand(sql, con);
        cmd.Connection.Open();
        try
        {
            cmd.ExecuteNonQuery();
        }
        catch
        {
            //MessageBox.Show(ex.Message);
        }
        finally
        {
            cmd.Connection.Close();
        }