Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help with this windows form application in C# using VS . The image depicts the application I need help with. I am able to

Need help with this windows form application in C# using VS. The image depicts the application I need help with. I am able to get the names to show but I also need a DataRow and get the Course Title for the other text box; and also need a query from the student table and use the course id from the text box to find students with that course Id. Then have them added to the list box. I am stuck and left off here. using Microsoft.Data.SqlClient;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CourseProject
{
public partial class WhoIsInCourse : Form
{
public WhoIsInCourse()
{
InitializeComponent();
using SqlConnection conn = new(Properties.Settings.Default.connString);
using SqlDataAdapter adapter = new("SELECT * FROM student", conn);
DataTable advisorTable = new();
adapter.Fill(advisorTable);
studentListBox.DisplayMember = "studentName";
studentListBox.ValueMember = "studentId";
studentListBox.DataSource = advisorTable;
}
//Close form
private void closeButton_Click(object sender, EventArgs e)
{
this.Close();
}
private void findButton_Click(object sender, EventArgs e)
{
//To-do search course database table using course ID. Update course name text box and then update student
//list box with all students enrolled in that course
using SqlConnection conn = new(Properties.Settings.Default.connString);
using SqlDataAdapter adapter = new("SELECT * FROM courses WHERE courseId = @courseId", conn);
adapter.SelectCommand.Parameters.AddWithValue("@courseId", courseIdTextBox.Text);
DataTable courseIdTable = new();
adapter.Fill(courseIdTable);
}
}
}
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional SQL Server 2012 Internals And Troubleshooting

Authors: Christian Bolton, Justin Langford

1st Edition

1118177657, 9781118177655

More Books

Students also viewed these Databases questions

Question

Draw a picture consisting parts of monocot leaf

Answered: 1 week ago

Question

2 What are the steps that can aid effective communication?

Answered: 1 week ago