用户删除SQL中Tabel的最后一条记录时如何显示警告消息 [英] How to display warning message when user delete last record of tabel in sql

查看:84
本文介绍了用户删除SQL中Tabel的最后一条记录时如何显示警告消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个应用程序,其中用户有权从数据库中删除记录.我希望表中必须有一个记录.用户无法从表中删除最后一条记录,并显示错误消息至少必须有一个数据"

i m creating an application in which user has given right to delete record from database. I want there must be one record available in table. user can''t delete last record from table and disaply error message that ''At least one data must be available''

推荐答案

im正在创建应用程序用户有权从数据库中删除记录.我希望表中必须有一条记录
在后端使用存储过程删除记录.在您的存储过程中,首先检查记录数.如果大于一个,则将其删除并返回,否则执行也不删除并返回一条消息,提示一条记录,并且无法删除.

要了解SP,请访问:
MSDN:HOW TO:使用Visual C#.NET在ASP.NET中调用SQL Server存储过程 [ MSDN:HOW TO:使用ADO.NET和Visual C#.NET调用参数化存储过程 [ ADO.NET:使用存储过程 [ MSDN:创建过程(Transact-SQL) [
i m creating an application in which user has given right to delete record from database. I want there must be one record available in table
Use stored Procedure at the back end to delete the record. In your stored procedure, first check the number of records. If it is greater then one, then delete it and return or else do nor delete and return with a message that there is one record and it cannot be deleted.

To learn about SP''s, go here:
MSDN: HOW TO: Call SQL Server Stored Procedures in ASP.NET by Using Visual C# .NET[^]
MSDN: HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET[^]
ADO.NET : Using Stored Procedures[^]
MSDN: CREATE PROCEDURE (Transact-SQL)[^]


这篇关于用户删除SQL中Tabel的最后一条记录时如何显示警告消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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