see how to use Response.Redirect instead of FormsAuthentication.RedirectFromLoginPage:
Code replacing call to FormsAuthentication.RedirectFromLoginPage
http://www.macromedia.com/devnet/mx/dreamweaver/articles/forms_authentication/listing4.html
Code replacing call to FormsAuthentication.RedirectFromLoginPage
http://www.macromedia.com/devnet/mx/dreamweaver/articles/forms_authentication/listing4.html
Response.Redirect("admin.aspx");===>FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
1, // version
Username.Text, // get the username
DateTime.Now, // issue time is now
DateTime.Now.AddMinutes(30), // expires in 30 minutes
false, // cookie is not persistent
"member"); // role assignment is stored in the UserData
HttpCookie cookie = new HttpCookie( FormsAuthentication.FormsCookieName,
FormsAuthentication.Encrypt(ticket) );Response.Cookies.Add(cookie);
Response.Redirect("admin.aspx");
有错误。
请问思归大哥:SqlDataReader怎样可以读取数据?
我前面的设置是:
SqlConnection conn = new SqlConnection("Server=tomgus-master;UID=sa;PWD=1111;Initial Catalog=yqsb");
if (conn.State == ConnectionState.Closed)
{
conn.Open();
}
SqlCommand cmd = new SqlCommand();
string sql = "";
sql = "SELECT COUNT(*) AS number_users_found FROM security WHERE (username = '" + Username.Text + "') AND (password = '" + Password.Text + "')";
cmd.CommandType = CommandType.Text;
cmd.CommandText = sql;
cmd.Connection = conn;
SqlDataReader reader = cmd.ExecuteReader();
string sql = "";
sql = "SELECT COUNT(*) AS number_users_found FROM security WHERE (username = '" + Username.Text + "') AND (password = '" + Password.Text + "')";
cmd.CommandType = CommandType.Text;
cmd.CommandText = sql;
cmd.Connection = conn;
int nCount = (int)cmd.ExecuteScalar();