if(this.TextBox1.Text==""||this.TextBox2.Text=="")
{
Response.Write(@"<script language='javascript1.1'>alert('请输入帐号或密码')</script>");
}
else
{
SqlConnection con = new SqlConnection();
con.ConnectionString ="Data Source = 405-22;database = bbs_data;uid = sa;pwd=";
SqlCommand com = new SqlCommand();
string a = "select userID,userPWD from user_info where userID='"+TextBox1.Text+"'and userPWD='"+TextBox2.Text+"'";
com.CommandText = a;
com.Connection = con;
SqlDataReader dr = null;
com.Connection.Open();
dr = com.ExecuteReader();
if(dr.Read())
{
Response.Redirect("lt_back.aspx");
}
else
{
Response.Redirect("lt_chucuo.aspx");
}
}
--------------------------------------------------------------------------------------------------------------------------------------------
if(this.textBox1.Text == ""||this.textBox2.Text == "")
{
MessageBox.Show("请输入用户名或密码!");
}
else
{
string consql = "server=(local);database = stu_data;uid = sa;pwd=";
string selsql = "select user_name,user_pwd from user_info where user_name = '"+textBox1.Text+"' and user_pwd = '"+textBox2.Text+"'";
SqlConnection con = new SqlConnection(consql);
SqlCommand com = new SqlCommand(selsql,con);
try
{
con.Open();
SqlDataReader sdr =null;//数据读取器
sdr=com.ExecuteReader();
if(sdr.Read())
{
mian m =new mian();
m.ShowDialog();
}
else
{
MessageBox.Show("登录名或密码不正确!");
}
}
catch(Exception ex)
{
MessageBox.Show("登陆失败"+ex.Message);
}
finally
{
con.Close();
}
}