数据库表中没有删除记录 [英] No delete record in the database table

查看:68
本文介绍了数据库表中没有删除记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

演示层

----------------------



PRESENTATION LAYER
----------------------

private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
    if (e.ColumnIndex < 1)
    {
        string cid = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
        //MessageBox.Show(cid);
        DialogResult dr = MessageBox.Show("Are you sure want to delete the record permenantly ?", "Confirm Delete", MessageBoxButtons.YesNo);
        if (dr == DialogResult.Yes)
        {
            obj.DELETE_CUSTOMER(dataGridView1.CurrentRow.Index);
            Binddata();
        }

    }
}



CLASS LIBRARY

------ ------------


CLASS LIBRARY
------------------

public Database db;
   public CustomerDataManagement(string csstring)
   {
       db = DatabaseFactory.CreateDatabase(csstring);
   }

// DELETE CUSTOMER DATA
       private const string USP_Delete_Customer_Data = "USP_Delete_Customer_Data";
       private const string USP_Delete_Customer_Data_PARAM_1 = "customer_id";

public int DELETE_CUSTOMER(int customer_id)
   {
       try
       {

           DbCommand com = db.GetStoredProcCommand(USP_Delete_Customer_Data);
           db.AddInParameter(com, USP_Delete_Customer_Data_PARAM_1, DbType.Int32, customer_id);
           return db.ExecuteNonQuery(com);
       }
       catch (Exception)
       {
           throw;
       }
   }







不删除记录?

------------------



删除了SHOUTING,添加了代码块 - OriginalGriff [/编辑]




Not delete record?
------------------

[edit]SHOUTING removed, code blocks addded - OriginalGriff[/edit]

推荐答案

最可能的原因是:

1)你的存储过程做了你不想要的事情 - 没有看到它,我们无法判断。

2)您的行索引与数据库中的customer_id不同。



个人?我会看一下选项2.行索引将按顺序始终为0..n。您的ID数据库反映该订单的可能性非常小,特别是如果删除了一两个客户。



检查您的ID,以及您传递的价值通过 - 您可能希望从列中获取ID。
The most likely reasons are:
1) Your stored procedure does something you do not expect - without seeing it, we can''t tell.
2) Your row index is not the same as a customer_id in the database.

Personally? I''d look at option 2. Row indexes will always be 0..n in sequential order. It is very, very unlikely that your database of IDs reflects that order, particularly if a customer or two is deleted.

Check your IDs, and the value you are passing through - you probably want to get the ID from a column instead.


这篇关于数据库表中没有删除记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆