protected bool val() //VAL是类型转换函数。把字符串转换为数值。

[复制链接]
查看11 | 回复1 | 2010-6-18 15:51:41 | 显示全部楼层 |阅读模式
protected bool val() //VAL是类型转换函数。把字符串转换为数值。

{

string conn = Convert.ToString(ConfigurationManager.ConnectionStrings["SmallHouseConn"]);

SqlConnection sqlcon = new SqlConnection(conn);

sqlcon.Open();

string sqlstr = "select count(*) from homeHold where uid='" + TextBox2.Text.ToString() + "'";
//Response.Write(sqlstr);

SqlCommand scd = new SqlCommand(sqlstr, sqlcon);

int count = Convert.ToInt32(scd.ExecuteScalar());

//Response.Write(count);

//Response.End();

if (count <= 0)

{

return true;

}

else

{

return false;

}

}
}
谁能帮我详细解释一下啊

回复

使用道具 举报

千问 | 2010-6-18 15:51:41 | 显示全部楼层
protected bool val() //判断是否有uid为查询内容的数据{//获取web.config里的连接数据库字符串string conn = ConfigurationManager.ConnectionStrings["SmallHouseConn"].ToString();//打开数据库连接SqlConnection sqlcon = new SqlConnection(conn);sqlcon.Open();//查询字符串 查询是否有uid为关键字的数据string sqlstr = "select count(*) from homeHold where uid='" + TextBox2.Text
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行