Question: Using Visual Studio Windows Form App (.Net Framework) with C# . I got the following Windows application named ShowDataBase : This is the program :
Using Visual Studio Windows Form App (.Net Framework) with C# . I got the following Windows application named ShowDataBase :
This is the program :

This is the display with the database given up to now :

GIVEN CODE :
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.OleDb; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms;
namespace MostrarDataBase { public partial class MostrarDataBaseForm : Form { string Surname, Name; double Cost; // Step 1. We configure the connection target // string ConnectionString = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = travel.mdb
OleDbConnection cn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " + "Data Source=travel.mdb"); public MostrarDataBaseForm() { InitializeComponent(); }
private void label2_Click(object sender, EventArgs e) {
}
private void MostrarDataBaseForm_Load(object sender, EventArgs e) {
// Opening the connection to the Travel.mdb database cn.Open ();
MessageBox.Show ("The state of the connection is" + cn.State, "State", MessageBoxButtons.OK, MessageBoxIcon.Information);
// Step 2. Configuration of the Command object. string strSql = "Select * from TravelRequests"; // Creating the Command object OleDbCommand cmd = new OleDbCommand (strSql, cn);
// Step 3. Obtaining a DataReader, with the Execute Reader method OleDbDataReader myReader = cmd.ExecuteReader (); // "The number of fields that the TravelRequests table has is:" MessageBox.Show ("The number of fields that the TravelRequests table has is:" + myReader.FieldCount, "Fields", MessageBoxButtons.OK, MessageBoxIcon.Information); // Data type of field 7 MessageBox.Show ("DataType in field 7 of the TravelRequests table:" + myReader.GetFieldType (6), "DataType", MessageBoxButtons.OK, MessageBoxIcon.Information); // Name of field 7 MessageBox.Show ("The name of field 7 is:" + myReader.GetName (6), "DataType", MessageBoxButtons.OK, MessageBoxIcon.Information); // Checking if the query has the information (records-rows) Console.WriteLine ("Contains information ?:" + myReader.HasRows + "\ n \ n"); MessageBox.Show ("Contains information ?:" + myReader.HasRows, "DataType", MessageBoxButtons.OK, MessageBoxIcon.Information); label1.Text = string.Format ("{0,15} {1, -15} {2,15}", myReader.GetName (2), myReader.GetName (1), myReader.GetName (6)); // Traversing the Travel.mdb database record by record // to the end of the table.
while (myReader.Read ()) { Name = myReader.GetValue (2) .ToString (); Surname = myReader.GetValue (1) .ToString (); Cost = double.Parse (myReader.GetValue (6) .ToString ()); label1.Text + = Environment.NewLine + string.Format ("{0, -15} {1, -15} {2,15: C2}", Name, Surname, Cost); } // Closing the connection myReader.Close (); cn.Close (); } } }
The Windows Form uses this Access Database :
Instructions :
1- Add dialog windows that display the names of fields 4, 5, and 6 in the table. 2- Modify the code to display output similar to the following:

Form1 x Data Band Access in Connected Mode label1 Form1 Data Band Access in Connected Mode First Name Last Name Ceasar Guridy Janet Dunford Kaylee Swanson Jan Hall Madison Tirrell Austin James Braelyn Douglas Ramona Coveny Daniel Henry Keshav Dhiren Sean Ellis Faith Roberts Jordan Ramsey Cordell Tucker Desean Marcos Davon Marques Travel Cost $348.81 $1,945.91 $1,208.42 $2,900.29 $2,275.18 $1,740.10 $628.91 $850.13 $943.26 $2,143.02 $1,670.89 $599.95 $1,855.66 $1,555.11 $2,330.59 $759.42 Tables TravelRequests TravelRequests Employee - Last Name - First Name - 119 Guridy Ceasar 123 Dunford Janet 128 Swanson Kaylee 221 Hall Jan 242 Tirrell Madison 324 James Austin 365 Douglas Braelyn 378 Coveny Ramona 426 Henry Daniel 429 Dhiren Keshav 628 Ellis Sean 656 Roberts Faith 736 Ramsey Jordan 924 Tucker Cordell 941 Marcos Desean 949 Marques Davon Purpose for Travel Investment Banking Stock & Annuties Meeting H.R. Convention International Mgmt. Meeting Annuities Investments Utilities Investments Technology Recruiting Event Financial Seminar Communications Symposium Microsoft Event Interactive Marketing Online Marketing Event Risk Assement and Management Method Validation Stock Systems Conference Information Management Location Trip Dates Richmond, VA August 1-2, 2008 Charleston, West Virginia November 19-23, 2008 Chicago, Illinois March 10-12, 2008 Atlanta, Georgia February 2-6, 2008 Albany, New York April 26-29, 2008 Salem, Oregon March 20-23, 2008 Houston, Texas September 29-30, 2008 Trenton, New Jersey July 25, 2008 Sacramento, California June 6, 2008 Redmond, Washington July 9-15, 2008 Los Angeles, California November 6-10, 2008 Richmond, Virgina August 21, 2008 Raleigh, North Carolina Auguest, 22-25 Baton Rouge, Louisiana May 3-6, 2008 Columbus, Ohio September 15-19, 2008 Providence, Rhode Island September 30, 2008 Travel Cost - Click to Add $348.81 $1,945.91 $1,208.42 $2,900.29 $2,275.18 $1,740.10 $628.91 $850.13 $943.26 $2,143.02 $1,670.89 $599.95 $1,855.66 $1,555.11 $2,330.59 $759.42 $0.00 Travel List Purpose/Date: Investment Banking, August 1-2, 2008 Ceasar Guridy $348.81 Purpose/Date: Stock & Annuties Meeting, November 19-23, 2008 Janet Dunford $1,945.91 Purpose/Date: H.R. Convention, March 10-12, 2008 Kaylee Swanson $1,208.42 Purpose/Date: International Mgmt. Meeting, February 2-6, 2008 Jan Hall $2,900.29 Purpose/Date: Annuities Investments, April 26-29, 2008 Madison Tirrell $2,275.18 Form1 x Data Band Access in Connected Mode label1 Form1 Data Band Access in Connected Mode First Name Last Name Ceasar Guridy Janet Dunford Kaylee Swanson Jan Hall Madison Tirrell Austin James Braelyn Douglas Ramona Coveny Daniel Henry Keshav Dhiren Sean Ellis Faith Roberts Jordan Ramsey Cordell Tucker Desean Marcos Davon Marques Travel Cost $348.81 $1,945.91 $1,208.42 $2,900.29 $2,275.18 $1,740.10 $628.91 $850.13 $943.26 $2,143.02 $1,670.89 $599.95 $1,855.66 $1,555.11 $2,330.59 $759.42 Tables TravelRequests TravelRequests Employee - Last Name - First Name - 119 Guridy Ceasar 123 Dunford Janet 128 Swanson Kaylee 221 Hall Jan 242 Tirrell Madison 324 James Austin 365 Douglas Braelyn 378 Coveny Ramona 426 Henry Daniel 429 Dhiren Keshav 628 Ellis Sean 656 Roberts Faith 736 Ramsey Jordan 924 Tucker Cordell 941 Marcos Desean 949 Marques Davon Purpose for Travel Investment Banking Stock & Annuties Meeting H.R. Convention International Mgmt. Meeting Annuities Investments Utilities Investments Technology Recruiting Event Financial Seminar Communications Symposium Microsoft Event Interactive Marketing Online Marketing Event Risk Assement and Management Method Validation Stock Systems Conference Information Management Location Trip Dates Richmond, VA August 1-2, 2008 Charleston, West Virginia November 19-23, 2008 Chicago, Illinois March 10-12, 2008 Atlanta, Georgia February 2-6, 2008 Albany, New York April 26-29, 2008 Salem, Oregon March 20-23, 2008 Houston, Texas September 29-30, 2008 Trenton, New Jersey July 25, 2008 Sacramento, California June 6, 2008 Redmond, Washington July 9-15, 2008 Los Angeles, California November 6-10, 2008 Richmond, Virgina August 21, 2008 Raleigh, North Carolina Auguest, 22-25 Baton Rouge, Louisiana May 3-6, 2008 Columbus, Ohio September 15-19, 2008 Providence, Rhode Island September 30, 2008 Travel Cost - Click to Add $348.81 $1,945.91 $1,208.42 $2,900.29 $2,275.18 $1,740.10 $628.91 $850.13 $943.26 $2,143.02 $1,670.89 $599.95 $1,855.66 $1,555.11 $2,330.59 $759.42 $0.00 Travel List Purpose/Date: Investment Banking, August 1-2, 2008 Ceasar Guridy $348.81 Purpose/Date: Stock & Annuties Meeting, November 19-23, 2008 Janet Dunford $1,945.91 Purpose/Date: H.R. Convention, March 10-12, 2008 Kaylee Swanson $1,208.42 Purpose/Date: International Mgmt. Meeting, February 2-6, 2008 Jan Hall $2,900.29 Purpose/Date: Annuities Investments, April 26-29, 2008 Madison Tirrell $2,275.18
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
