ASP.Net简单更新方法举例

    public int Update()
    {
        string sql = "update student set
xingming=@xingming where xuehao=@xuehao";
        DataTable dt = new DataTable();
        SqlConnection conn = new SqlConnection();
        conn.ConnectionString = @"Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True";
        SqlCommand command = new SqlCommand(sql,conn);
        SqlParameter parm = new SqlParameter("@xuehao","001");
        command.Parameters.Add(parm);
        parm = new SqlParameter("@xingming", "张三");
        command.Parameters.Add(parm);
        try
        {
            conn.Open();
            return command.ExecuteNonQuery();
        }
        catch (SqlException ex)
        {
            return -1;
        }
        finally
        {
            conn.Close();
        }
    }

ASP.Net简单更新方法举例,布布扣,bubuko.com

ASP.Net简单更新方法举例

上一篇:纯CSS仿制Google女生节Doodle


下一篇:java拼写json