这个登陆功能的代码缺了一部分,需要怎么补充

protected void LoginSubmit_click(object sender,EventArgs e)
{
string uname = name.Text.Trim( );
string pwd = password . Text.Trim( );
sqlConnection connection = new SqlConnection(ConfigurationIManager.connectionStrings["connectionString"].Tostring();
string sql = string.Format("select count(*) from userinfo where username='{0]}’ and passwond= '(1]"",uname,pad);
sqlcommand command = new sqlcommand(sql,connection);
connection.Open();
int a = (int)command.Executescalar();
connection.Close();
if (a > 0)//登陆成功{
Session[ "admin_user" ] = uname;}
else {//登陆失败
Response.write(" ");}
}

这是按你的要求修改的完整代码

 protected void LoginSubmit_click(object sender, EventArgs e)
        {
            string uname = name.Text.Trim();
            string pwd = password.Text.Trim();
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["connectionString"].ToString());
            string sql = string.Format("select count(*) from userinfo where username='{0}'  and passwond= '{1}'", uname, pwd);
            SqlCommand command = new SqlCommand(sql, connection);
            connection.Open();
            int a = (int)command.ExecuteScalar();
            connection.Close();
            if (a > 0)
            {
                //登陆成功
                Session["admin_user"] = uname;
            }
            else
            {
                //登陆失败
                Response.Write(" ");
            }
        }

你好,
1.你的"connectionString" 在web.config 中写了吗? 连接数据库了吗?
2.sql 语句里面的[], () 都写的不匹配
3.你有限制名字和密码唯一吗? 如果两个人是相同的名字,相同的密码,你要怎么办?
这两天你的问题来来回回都是一样的问题! 都是sql 的连接, 其实就那么几个 步骤, 你先去看看具体步骤, 多运行几遍就会了!