View Full Version : چک کردن سشن با مقدار فیلد درون جدول؟
boysilent
شنبه 17 دی 1390, 22:53 عصر
سلام:دوستان عزیز میخواستم ببینم چطوری میشه یه سشن رو با فیلئ داخل پایگاه مقایسه کرد؟
SqlDataReader reader;
SqlConnection newcon = new SqlConnection("Data Source=.;Initial Catalog=wordha;Integrated Security=True");
SqlCommand newcom = new SqlCommand();
newcom.Connection=newcon;
newcom.CommandText="SELECT * FROM wlogin ";
newcon.Open();
reader=newcom.ExecuteReader(); }
reader.Close();
newcon.Close();
؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟
if (Session["session_uname"] ==؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟ بگم با خونه یوزر؟؟؟چطوری)
{
Response.Redirect("default2.aspx");
}
؟؟؟؟؟؟؟؟؟؟؟؟؟؟/
fakhravari
شنبه 17 دی 1390, 23:46 عصر
reader["name"]
boysilent
یک شنبه 18 دی 1390, 00:55 صبح
newcon.Open();
reader = newcom.ExecuteReader();
if (Session["session_uname"] ==reader["uname"].ToString() & Session["session_pword"] ==reader["pword"].ToString())
{
Label1.Text = reader["uname"].ToString();
به نظر شما این سشن مشکلی داره؟؟؟؟؟ اخه خطو خطا میده
fakhravari
یک شنبه 18 دی 1390, 01:20 صبح
2تا && لازمه
boysilent
یک شنبه 18 دی 1390, 08:19 صبح
اقا این کد های منه دوباره ببینید چرا خطا میده
protected void Page_Load(object sender, EventArgs e)
{
if (Session["s_uname"] == null)
{
Response.Redirect("default2.aspx");
}
SqlDataReader reader;
SqlConnection newcon = new SqlConnection("Data Source=.;Initial Catalog=wordha;Integrated Security=True");
SqlCommand newcom = new SqlCommand();
newcom.Connection = newcon;
newcom.CommandText = "SELECT * FROM wlogin ";
//newcom.Parameters.AddWithValue("@uname", TextBox1.Text);
//newcom.Parameters.AddWithValue("@pword", TextBox2.Text);
newcon.Open();
reader = newcom.ExecuteReader();
؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟این قسمتش خطا داره و سبز میشهif (Session["s_uname"] ==reader["uname"].ToString())
{
Label1.Text = reader["uname"].ToString();
reader.Close();
newcon.Close();
}
else
{
Label1.Text="no";
}
}
}
crazy_1892
یک شنبه 18 دی 1390, 10:37 صبح
اقا این کد های منه دوباره ببینید چرا خطا میده
protected void Page_Load(object sender, EventArgs e)
{
if (Session["s_uname"] == null)
{
Response.Redirect("default2.aspx");
}
SqlDataReader reader;
SqlConnection newcon = new SqlConnection("Data Source=.;Initial Catalog=wordha;Integrated Security=True");
SqlCommand newcom = new SqlCommand();
newcom.Connection = newcon;
newcom.CommandText = "SELECT * FROM wlogin ";
//newcom.Parameters.AddWithValue("@uname", TextBox1.Text);
//newcom.Parameters.AddWithValue("@pword", TextBox2.Text);
newcon.Open();
reader = newcom.ExecuteReader();
؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟این قسمتش خطا داره و سبز میشهif (Session["s_uname"] ==reader["uname"].ToString())
{
Label1.Text = reader["uname"].ToString();
reader.Close();
newcon.Close();
}
else
{
Label1.Text="no";
}
}
}
چه خطایی میده؟
boysilent
یک شنبه 18 دی 1390, 14:39 عصر
آقا فقط همون قسمت سبز میشه و میگه to string???????????????
hamid_shrk
یک شنبه 18 دی 1390, 15:05 عصر
همین کد رو من گذاشتم خطا نداشت!!!
boysilent
یک شنبه 18 دی 1390, 23:26 عصر
متن خطاش اینه
Invalid attempt to read when no data is present."
صقخه قبلیش هم اینجوری تعریف کردم
Session.Add("s_uname",TextBox1.Text);
Session.Add("s_pword", TextBox2.Text);
Response.Redirect("modiriat.aspx");
Saman Hashemi
دوشنبه 19 دی 1390, 08:49 صبح
قبل از خوند از reader باید خط زیر چک کنید و بعد بخونید...!
if(reader.Read()){
}
boysilent
دوشنبه 19 دی 1390, 10:06 صبح
اوکی شد مرسی برادرا..
اقا برای ز بین بردن سیشن مگه این دستور نیست؟
session.cleare();
نمیدونم چرا اجرا نمیشه؟؟؟
با ieمشکل نداره احیانا؟؟؟
fakhravari
دوشنبه 19 دی 1390, 13:42 عصر
Session.RemoveAll();
boysilent
دوشنبه 19 دی 1390, 14:59 عصر
بنده همین کد رو نوشتم ولی متاسفانه هیچ هملی انجتم نمی دهد؟؟؟؟؟؟
باورتون نمیشه ؟
Session.RemoveAll();
Response.Redirect("Default2.aspx");
hamid_shrk
دوشنبه 19 دی 1390, 15:02 عصر
اینارو هم امتحان کن :
Session.Abandon();
Session.Contents.Clear();
vBulletin® v4.2.5, Copyright ©2000-1403, Jelsoft Enterprises Ltd.