Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C# in Visual Basic Form I cant figure out how to generate the information for the popLabel. Can someone please help! I can get the

C# in Visual Basic Form

I cant figure out how to generate the information for the popLabel. Can someone please help!

I can get the state list to populate from the state table but I cannot figure out how to query the information from the county tabel to pull the information below and generate the popLabel as seen below.

image text in transcribed

image text in transcribed

image text in transcribed image text in transcribed

image text in transcribed

CODE I CURRENTLY HAVE:

using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Windows.Forms;

namespace Exam2 { static class Program { ///

/// The main entry point for the application. /// [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } } }

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; using System.Data.SqlClient;

namespace Exam2 { public partial class Form1 : Form { string connectionString; SqlConnection connection; SqlDataAdapter adapter;

public Form1() { InitializeComponent(); InitialDatabaseObjects(); LoadStateListBox(); CloseDatabaseoObjects(); } public void InitialDatabaseObjects() { connectionString = "Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename= C:\\Users\\Lesley Cadden\\OneDrive\\ANDERSON UNIVERSITY\\Spring 2018\\Exam2\\census.mdf; Integrated Security = True; Connect Timeout = 30"; connection = new SqlConnection(connectionString); connection.Open(); } public void CloseDatabaseoObjects() { connection.Close(); } public void LoadStateListBox() { string query = "SELECT * FROM state"; DataTable stateTable;

stateTable = new DataTable(); adapter = new SqlDataAdapter(query, connection); adapter.Fill(stateTable);

stateListBox.Items.Clear(); foreach (DataRow row in stateTable.Rows) { stateListBox.Items.Add(row[1]); } } } }

1. 2. Create a form that contains a list box control and at least one label control. Populate the list box control with the states names found in the state table of the census.mdf database. 3. When a state name is selected in the list box, display the following information in a label control to the right of the list box: o The name of the selected state o The total population of the selected state o The name and population of the county within the state which has the largest population o The name and population of the county within the state which has the smallest population You will need to query the county table of the database in order to gather the necessary population information

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

Transactions On Large Scale Data And Knowledge Centered Systems Xxviii Special Issue On Database And Expert Systems Applications Lncs 9940

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Qimin Chen

1st Edition

3662534541, 978-3662534540

More Books

Students also viewed these Databases questions

Question

politeness and modesty, as well as indirectness;

Answered: 1 week ago