数据库表中没有删除记录

编程入门 行业动态 更新时间:2024-10-28 03:29:30
本文介绍了数据库表中没有删除记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

演示层 ----------------------

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.

更多推荐

数据库表中没有删除记录

本文发布于:2023-10-22 08:48:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1517026.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据库

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!