سلام مشکلی در لوگین کردن دارم لطفا راهنمایی کنین.
این کد رو در صفحه Login.aspx نوشتم
protected void btnSubmit_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=kardata;Integrated Security=True");
SqlCommand cmd = new SqlCommand("SELECT * FROM Afrad WHERE FirstName=@user AND LastName=@pass", con);
cmd.Parameters.AddWithValue("@user", txtid);
cmd.Parameters.AddWithValue("@pass", txtpass);
con.Open();
SqlDataReader rdr =null;
rdr = cmd.ExecuteReader();
rdr.Read();
if (rdr.Read())
{
FormsAuthentication.RedirectFromLoginPage(txtid.Text, chk_member.Checked);
}
else
{
Label1.Visible = true;
}
}
اینم کد web.config:
<?xml version="1.0"?>
<configuration>
<system.web>
<customErrors mode="Off"/>
<authentication mode="Forms">
<forms name="MyAppCookie" loginUrl="Login.aspx" protection="All" timeout="30" defaultUrl="Default.aspx" ></forms>
</authentication>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
<location path="Register.aspx">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
</configuration>
ولی و قتی میخوام لوگین شم این خطا رو میده
No mapping exists from object type System.Web.UI.WebControls.TextBox to a known managed provider native type
این کد رو در صفحه Login.aspx نوشتم
protected void btnSubmit_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=kardata;Integrated Security=True");
SqlCommand cmd = new SqlCommand("SELECT * FROM Afrad WHERE FirstName=@user AND LastName=@pass", con);
cmd.Parameters.AddWithValue("@user", txtid);
cmd.Parameters.AddWithValue("@pass", txtpass);
con.Open();
SqlDataReader rdr =null;
rdr = cmd.ExecuteReader();
rdr.Read();
if (rdr.Read())
{
FormsAuthentication.RedirectFromLoginPage(txtid.Text, chk_member.Checked);
}
else
{
Label1.Visible = true;
}
}
اینم کد web.config:
<?xml version="1.0"?>
<configuration>
<system.web>
<customErrors mode="Off"/>
<authentication mode="Forms">
<forms name="MyAppCookie" loginUrl="Login.aspx" protection="All" timeout="30" defaultUrl="Default.aspx" ></forms>
</authentication>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
<location path="Register.aspx">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
</configuration>
ولی و قتی میخوام لوگین شم این خطا رو میده
No mapping exists from object type System.Web.UI.WebControls.TextBox to a known managed provider native type