如何停止添加&将空数据更新到SQL数据库 [英] how to stop adding & updating null data to SQL database

查看:71
本文介绍了如何停止添加&将空数据更新到SQL数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有关于员工个人数据的Windows表单。我想在填写windows表单的所有文本框后添加数据。

I have windows form which is about employee personal data.I want to add data after filling all text boxes of the windows form.

推荐答案

对所有人进行验证保存前的控件。
Do validation for all the controls before saving.


尝试此操作以检查TextBox1或TextBox2是否为空。如果没有保存它们。



Try this to check if TextBox1 or TextBox2 are empty . If there are not save them.

 if ((String.IsNullOrEmpty(TextBox1.Text)) || (TextBox1.Text == "0")||(String.IsNullOrEmpty(TextBox2.Text)) || (TextBox2.Text == "0")|| etc...)
            {
                string Msg = "<script>alert('The textbox cannot be empty or zero!');</script>";
                ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "alert", Msg, false);
            }
            else
{
//here put your code
}
            {


这篇关于如何停止添加&amp;将空数据更新到SQL数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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