日期:2014-05-17  浏览次数:20878 次

C# 无法修改数据库里的数据
string conString = @"data source=.\SQLEXPRESS;Database=XXXX_database;User Id=sa;Pwd=123456";
            using (SqlConnection connection = new SqlConnection(conString))
            {
                try
                {
                    connection.Open();
                    string strSQL = "Update MainTable Set State = '0' where ID = '201'";
                    SqlCommand sqlcom = new SqlCommand(strSQL, connection);
                }
                catch (System.Data.SqlClient.SqlException ex)
                {
                    throw new Exception(ex.Message);
                }
            }

在SQL Server Management Studio上运行修改成功,用C#进行修改则不行,查询语言也可以查询成功。
高手相助,本人为这个要抓狂了~
c# 数据库 SQL Update

------解决方案--------------------
没执行啊,sqlcom.ExecuteNonQuery()