السلام عليكم ورحمة الله وبركاته
اولاً اشكر كل القائمين والمشاركين في هذا المنتدى الرائع
ثانياً اتمنى منكم مساعدتي في مشكلتي
ولا ادري هل العنوان مناسب للمشكلة ام لا اذا كان غير مناسب اتمنى من المشرف تعديله.
مشكلتي هي (اولاً دعوني اشرح لكم الفكره )
عندي صفحة فيها 2 تكست بوكس وواحد دروب داون ليست وبوتن
مثل الصوره التاليه
ابغى لما تجي طالبه تبغى تشوف نتيجتها تدخل رقم القيد في التكست بوكس ون وتدخل كلمة المرور في التكست بوكس 2 (علماً بان ليست لكل الطالبات والطلاب كلمة مرور للبعض فقط ) وتختار الترم من الدروب داون ليست وتضغط على البوتن وتنعرض نتئجتها في قريدفيو واحد مكون من عمودين اسم الماده والدرجة.
وهذا كود البوتن :
protected void Button1_Click(object sender, EventArgs e)
{
string sqlConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|Insert.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
SqlConnection con = new SqlConnection(sqlConnectionString);
con.Open();
//and dep_ID in (Select dep_ID from Stu_Info where Stu_reg_no = '" + TextBox3.Text + "' and Level in (Select Stu_Level from Stu_Info where Stu_reg_no = '" + TextBox3.Text + "'))
//and Results.SubID in (select SubID from Subjects where Term =" + DropDownList1.SelectedValue + " and level in (Select Stu_Level from Stu_Info where Stu_reg_no = '" + TextBox3.Text + "') and Subjects.dep_ID in (Select dep_ID from Stu_Info where Stu_reg_no = '" + TextBox3.Text + "'))
//and SubID in (select SubID from Subjects where Level and dep_ID in (select Level,dep_ID from Stu_Info where Stu_reg_no='" + TextBox3 .Text + "')and term=" + DropDownList1.SelectedValue + " )
//and Results.SubID=Subjects.SubID
// SqlCommand cmd = new SqlCommand("SELECT distinct Sub_Name,Mark from Subjects,Results where Results.Stu_reg_no=" + TextBox3.Text + " and Subjects.SubID in (select SubID from subjects where Term=" + DropDownList1.SelectedValue + " and dep_ID in (Select dep_ID from Stu_Info where Stu_reg_no = '" + TextBox3.Text + "' )and Level in (Select Stu_Level from Stu_Info where Stu_reg_no = '" + TextBox3.Text + "'))", con);
SqlCommand cmd = new SqlCommand("SELECT اسم_الماده from Subjects where Subjects.SubID in (select SubID from subjects where Term=" + DropDownList1.SelectedValue + " and dep_ID in (Select dep_ID from Stu_Info where Stu_reg_no = '" + TextBox3.Text + "') and Level in (Select Stu_Level from Stu_Info where Stu_reg_no = '" + TextBox3.Text + "')) and Stu_Info in (SELECT Passowrd from Stu_Info where Passowrd = '" + TextBox2.Text + "')", con);
// and Passowrd in(Select Passowrd from Stu_Info = '" + TextBox2.Text + "')
//SqlCommand cmd1 = new SqlCommand("SELECT Passowrd from Stu_Info where Passowrd = '" + TextBox2.Text + "'", con);
// SqlCommand cmd = new SqlCommand("SELECT Sub_Name,Mark from Subjects,Results where Results.Stu_reg_no='" + TextBox3.Text + "' and Results.SubID in (select SubID from Subjects where Term =" + DropDownList1.SelectedValue + " and Level in (Select Stu_Level from Stu_Info where Stu_reg_no = '" + TextBox3.Text + "')))", con);
SqlDataReader myreader = default(SqlDataReader);
myreader = cmd.ExecuteReader();
GridView1.DataSource = myreader;
GridView1.DataBind();
myreader.Close();
///////////////////////
//
SqlCommand cmd2 = new SqlCommand("SELECT الدرجة from Results where Stu_reg_no='" + TextBox3.Text + "' and SubID in (select SubID from Subjects where Term=" + DropDownList1.SelectedValue + "and dep_ID in (Select dep_ID from Stu_Info where Stu_reg_no ='" + TextBox3.Text + "' )and Level in (Select stu_level from Stu_Info where Stu_reg_no ='" + TextBox3.Text + "'))", con);
// SqlCommand cmd = new SqlCommand("SELECT Sub_Name,Mark from Subjects,Results where Results.Stu_reg_no='" + TextBox3.Text + "' and Results.SubID in (select SubID from Subjects where Term =" + DropDownList1.SelectedValue + " and Level in (Select Stu_Level from Stu_Info where Stu_reg_no = '" + TextBox3.Text + "')))", con);
SqlDataReader myreader2 = default(SqlDataReader);
myreader2 = cmd2.ExecuteReader();
GridView2.DataSource = myreader2;
GridView2.DataBind();
myreader2.Close();
////////////////
/////////////////////////////////////////////
SqlCommand cmd3 = new SqlCommand("SELECT الاسم from Stu_Info where Stu_reg_no='" + TextBox3.Text + "'", con);
// SqlCommand cmd = new SqlCommand("SELECT Sub_Name,Mark from Subjects,Results where Results.Stu_reg_no='" + TextBox3.Text + "' and Results.SubID in (select SubID from Subjects where Term =" + DropDownList1.SelectedValue + " and Level in (Select Stu_Level from Stu_Info where Stu_reg_no = '" + TextBox3.Text + "')))", con);
SqlDataReader myreader3 = default(SqlDataReader);
myreader3 = cmd3.ExecuteReader();
GridView3.DataSource = myreader3;
GridView3.DataBind();
myreader3.Close();
////////////////////////////////////////////////////
/*SqlConnection conn = new SqlConnection();
SqlDataAdapter da = new SqlDataAdapter();
DataSet ds = new DataSet();
string sql3 = null;
DataTable dt = new DataTable();
sql3 = "select * from Subjects";
da = new SqlDataAdapter(sql3, sqlConnectionString);
conn.Open();
SqlCommand cmd555 = new SqlCommand(sql3, conn);
ds.Clear();
da.Fill(dt);
conn.Close();
GridView1.DataSource = dt;
GridView1.DataBind();
//GridView1.DataSource = dt;
//GridView1.DataBind();
/*DataTable dTable = new DataTable();
da.Fill(dTable);
GridView dgView = new GridView();
BindingSource bSource = new BindingSource();
bSource.DataSource = dTable;
dgView.DataSource = bSource;
*/
TextBox3.Visible = false;
Label1.Visible = false;
}المطلوب هو كيف اسوي جملة استعلام واحده للتكست بوكس ون وهو رقم القيد والتكست بوكس 2 وهو لكلمة المرور ( يتحقق من جدول الطلاب اذا كان للطالبه كلمة مرور لا تستطيع مشاهدة نتيجتها الا بعد كتابة رقم القيد وكلمة المرور واذا كان لا يوجد لها كلمة مرور في حقل الباسوورد تستطيع مشاهدة نتئجتها برقم القيد فقط) ,وايضاً للدروب داون ليست واختيار الترم الاول ام الثاني. الاستعلام يكون للحقلين اسم_الماده ( من جدول الـ Subjects ) و الدرجة ( من جدول الـ Results) وعرضهم في GridView1
وهذه صورة من الجداول:
اتمنى ان اكون وضحت مشكلتي
واتمنى مساعدتكم لي .
وشكراً لكم
