Question
You are to create a C# Windows Forms (GUI) application that conforms to the following specifications: 1. Load a list box with information about library
You are to create a C# Windows Forms (GUI) application that conforms to the following specifications:
1. Load a list box with information about library patrons. The each list box item should contain a patron ID and a patron name. You will read information from the patron table of the database and use the information that you have retrieved from the database to load the list box.
2. Each time an item is selected in the patron list box, do the following: a. Retrieve all of the rows in the borrower table that are associated with the patronID of the item that was selected in the patron list box. b. Use the data retrieved from the borrow table (as described in the bullet above), and populate a list box with the following information: i. Book title ii. Book due date
Current Code I have
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
namespace Homework5
{
class Program
{
static string connectionString;
static SqlConnection connection;
static SqlDataAdapter adapter;
static void Main(string[] args)
{
InitializeDatabaseObjects();
CloseDatabase();
}
static void InitializeDatabaseObjects()
{
connectionString = ConfigurationManager.ConnectionStrings["Homework5.Properties.Settings.libraryConnectionString"].ConnectionString;
connection = new SqlConnection(connectionString);
connection.Open();
}
static void QueryPatronData()
{
string query = "SELECT * from Patron";
DataTable patronTable;
patronTable = new DataTable()
adapter = new SqlDataAdapter(query, connection);
adapter.Fill(patronTable);
}
static void CloseDatabase()
{
connection.Close();
}
}
Server Explorer l Azure lections.Generic; Data Connections library.mdf Tables eading.Tasks; Dborrow EE patron a.SqlClient; figuration; DViews DStored Procedures Functions DSynonyms Types Assemblies tring connectionString; q1Connection connection; qlDataAdapter adapter; Servers SharePoint Connections void Main(stringt] args) ializeDatabaseObjects); eDatabase 2 Errors | 1 warning | | 0 0 Me ion Program.adapter' is never used ReadyStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started