heey、私は学校の魔女のためのプロジェクトをやっていますが、SQLサーバデータベースを使ってasp.netにログインします。データベースにログイン名とパスワードがあります私はこれがクッキーを使用してのみ可能だったと聞いた、私は今一週間見て、それは2011年12月22日を準備する必要があります。 私はクエリを持っています。私はGridViewにanwserを置く場合結果-1良い結果を得る。 これは限り私はそれを持っているようBtn_Click上のコードです:ASP.NETでログインするwnhにSQLサーバが接続されている
protected void btnInloggen_Click(object sender, EventArgs e)
{
string sEMail = txtUserEMail.Text;
string sPassword = txtPassword.Text;
gvCookie.DataSource = SQL_codes.Inloggen(sEMail, sPassword);
gvCookie.DataBind()//this was to test my query;
HttpCookie cookUserName = new HttpCookie("Username");
cookUserName.Value = Convert.ToInt16(gvCookie);//thought something liek this would do it but it doesn't so what i want is the result of the query here
Response.Cookies.Add(cookUserName);
if (Request.Cookies["Username"] !=null)
{
string sName = Request.Cookies["Username"].Value;
Response.Write(sName);
}
}
、これは私が私のクエリを使用すべきだと思う私の方法です:
public static DataTable Inloggen(string sEMail, string sPassword)
{
string sql = string.Format("select OpdrachtGever.opdrid from OpdrachtGever where OpdrachtGever.eMail = '{0}' and OpdrachtGever.Password = '{1}'", sEMail, sPassword);
SqlDataAdapter da = new SqlDataAdapter(sql, SQL_codes.GetConnection());
DataTable dt = new DataTable("reserveringen");
da.Fill(dt);
return dt;
}
私はオランダ人だから(それはオランダ語でです
は今、私はたぶん私は変数に結果を置くことができますが、私は、これは君たち(または女の子が)私を助けることができれば
が、それは素晴らしいだろうどのように動作するかvindtすることはできません)申し訳ありません私は完全に詰まっているので
クッキーを使用する必要がありますか?クッキーを使用して物事を行うにはあまり安全ではありません.. – MethodMan