重复的名称不允许 [英] duplicate name not allow

查看:88
本文介绍了重复的名称不允许的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有''用户''表:

字段是:



名称

emailid < br $>
地址

ph.no

密码





$ b



当我从文本框中插入新数据时,它会检查名称是否已经是完全存在的。如果不是exsist则允许在文本框中输入名称。

如何做到这一点?



更多描述我的问题:

时我在文本框中输入名称,它将检查天气名称是否存在。如果名称为exsist,则不允许输入名称。

i have ''user'' table:
fields are:

name
emailid
address
ph.no
password





when i insert new data from textbox,it will check whether name is allready exsist or not .if not exsist then allow to enter name in textbox.
how to do this?

more discription of my problem:
when i enter name in textbox ,it will check weather name is exsist or not.if name exsist, then it will not allow to enter name.

推荐答案

嗨朋友..



插入按钮点击事件就这样做...



Hi Friend..

on insertion button click event just do this...

con.Open();
 MySqlCommand cmd = new MySqlCommand("select * from Your_tableUser where name=''"+txtboxName.text+"''", con);
        MySqlDataReader dr = cmd.ExecuteReader();
     if (dr.Read())
        {

            Lblmsg.text="Duplicate Entry Found..."; //label that show your error massage 

        }
else
{
Here Do You Insert Code....
}
        con.Close();





我认为这对你有帮助...



I think it will be helpful for you...


您可以使用

You can check using
string sql = string.format(" select count(*) from table name where name='{0}'", txtname.text);





如果它退出则给出1其他0

然后你可以允许进入。



if it exitst it gives 1 else 0
then u can allow to enter.


这篇关于重复的名称不允许的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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