asp.net c# 数据库是mysql 登录代码
答案:1 悬赏:40 手机版
解决时间 2022-01-01 04:21
- 提问者网友:一抹荒凉废墟
- 2021-12-31 20:34
asp.net c# 数据库是mysql 登录代码
最佳答案
- 五星知识达人网友:一袍清酒付
- 2021-12-31 21:01
string dbconstr="server=10.7.70.132;uid=root;pwd=sa123;database=ce_manage_db; pooling=false;charset=utf8"; //连接mysql数据库字串
protected void btnLogin_Click(object sender, ImageClickEventArgs e)
{
if (txtemp.Text == "" && txtpass.Text == "")//是否输入密码帐号
{
labmsg.Text="帐号或密码为空,请输入";
}
else
{
string sql2 = "select username from account_user_t where userid='" + txtemp.Text.Trim() + "' and password='" + txtpass.Text.Trim() + "'";
ds = MySqlHelper.ExecuteDataset(dbconstr, sql2);
if (ds.Tables[0].Rows.Count > 0) //密码帐号是否正确
{
Response.Redirect("~/Index.aspx");
}
else
{
labmsg.Text="帐号或密码错误";
}
}
}
protected void btnLogin_Click(object sender, ImageClickEventArgs e)
{
if (txtemp.Text == "" && txtpass.Text == "")//是否输入密码帐号
{
labmsg.Text="帐号或密码为空,请输入";
}
else
{
string sql2 = "select username from account_user_t where userid='" + txtemp.Text.Trim() + "' and password='" + txtpass.Text.Trim() + "'";
ds = MySqlHelper.ExecuteDataset(dbconstr, sql2);
if (ds.Tables[0].Rows.Count > 0) //密码帐号是否正确
{
Response.Redirect("~/Index.aspx");
}
else
{
labmsg.Text="帐号或密码错误";
}
}
}
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯