在access 数据库数据删除时,我想在执行完删除语句后返回一条结果来告诉我有没有删除成功,这个应该怎么做!
第一次使用access配合ASP.NET开发项目,不懂 呵呵!希望大家帮帮忙!谢谢。

解决方案 »

  1.   

    [color=#FF0000]protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        string text = "Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source=";
        OleDbConnection connection = new OleDbConnection(text + base.get_Server().MapPath(@"..\App_Data\Aqbiopharma.mdb"));
        string text2 = "delete from Product where ProductID=@ProductID";
        OleDbCommand command = new OleDbCommand(text2, connection);
        command.get_Parameters().AddWithValue("@ProductID", this.GridView1.get_DataKeys().get_Item(e.get_RowIndex()).get_Value());
        try
        {
            connection.Open();
            if (command.ExecuteNonQuery() > 0)
            {
                this.get_Page().get_ClientScript().RegisterStartupScript(base.GetType(), "", "<script>alert('删除成功')</script>");
            }
        }
        catch (Exception)
        {
        }
        finally
        {
            connection.Close();
        }
        this.BindComments();
    }