The code initializes a form that allows users to select a department from a combo box, specifically 'SW' and 'IT'. Upon selection, it retrieves and displays students from a database based on the chosen department. The data is fetched using a SQL query and displayed in a DataGridView control.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
2 views
ال
The code initializes a form that allows users to select a department from a combo box, specifically 'SW' and 'IT'. Upon selection, it retrieves and displays students from a database based on the chosen department. The data is fetched using a SQL query and displayed in a DataGridView control.
{ using (SqlConnection con = new SqlConnection("Data Source=DESKTOP-30OSUJ5\\ SQLEXPRESS;Initial Catalog=studentm;Integrated Security=True")) { string query = "SELECT * FROM studentn WHERE name7 = @Department"; // جلب الطالب حسب القسم SqlCommand cmd = new SqlCommand(query, con); cmd.Parameters.AddWithValue("@Department", department); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt);
dataGridView1.DataSource = dt; // عرض البيانات فيDataGridView