您的位置:首页 > 数据库

界面输入值和数据库值进行比较

2010-03-27 15:40 197 查看
protected void Button1_Click(object sender, EventArgs e)
{
if (TextBox1.Text != "")
{
string strConnection = "server=.;database=colorring;uid=sa;pwd=";
string strSql = "select top 1 ringid from s50usersysringgrp where ringid=@ringid";
SqlConnection con = new SqlConnection(strConnection);
SqlCommand com = new SqlCommand(strSql, con);
con.Open();

com.Parameters.Add("@ringid", SqlDbType.Char, 12).Value = TextBox1.Text;
SqlDataReader dr = com.ExecuteReader();
if (dr.Read())
{
TextBox2.Text = "数据库中有该ringid";
}
else
{
TextBox2.Text = "数据库中没有该ringid";
}
dr.Close();
con.Close();
}
else
{
TextBox2.Text = "你没有输入任何值";
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐