0
嗨,我正在运行两种形式的身份验证。我运行的第一个身份验证是AD身份验证,可以正常工作。其次是确认用户名在SQL数据库中。我正在使用此代码来验证用户名是否存在于SQL中。带有文本框和AD身份验证的SQL身份验证
我得到的错误
操作“==”不能应用于类型“字符串”和“System.Data.SqlClient.SqlDataReader”
与此代码的操作数....
using (SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString))
{
SqlCommand cmd = new SqlCommand("select Username from dbo.users", con);
con.Open();
SqlDataReader sqlresult = cmd.ExecuteReader();
if (txtLoginID.Text == sqlresult)
{
Response.Redirect("account/orders.aspx");// Authenticated user redirects to default.aspx
}
else
{
Response.Redirect("default.aspx");// Authenticated user redirects to default.aspx
}
con.Close();
}
}
您正在错误地使用SQLDataReader。检查[文档](http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader(v = vs.110).aspx)。 – RadioSpace 2014-09-29 22:59:44