string sql = " SELECT COUNT(Mobile) mcount FROM dbo.Yuanboguoji_student WHERE Mobile=‘" + txtMobile.Text.Trim() + "‘";
DataSet ds = DbHelperSQL.Query(sql);
int mcount = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
if (mcount > 0)
{
this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert(\"" + "号码已经存在;" + "\");location.reload();</script>");
return;
}原文:http://www.cnblogs.com/panqingqiang/p/4635593.html