Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this assignment, you must write two C# programs (Repurpose code pasted below ) that query your course project database: The first program must use

For this assignment, you must write two C# programs (Repurpose code pasted below) that query your course project database:

  • The first program must use one of the four types of loops youve learned about in this module to display the results of the SQL query (you must select at least 2 columns from the database), but then loop back through the program one time when the user presses a key.
  • The second program must use an array (hint: the program already uses an array to display the results of the query). However, this time, the array must only display the first and last names.

Format:

  • Your submission must include 2 text files and a Word document:
    • The text files must contain the code from your C# loop program [insert filename format here] and C# array program [insert filename format here].
    • The Word document must contain (4) screenshots:
      • (1) screenshot of your console application containing the loop program created in Visual Studio.
      • (1) screenshot of the loop program running in the Visual Studio console.
      • (1) screenshot of your console application containing the array program created in Visual Studio.
      • (1) screenshot of the array program running in the Visual Studio console.

Please repurpose the following code:

Code:

using System;

using System.Text;

using System.Data.SqlClient;

namespace HelloWorld

{

class Program

{

static void Main(string[] args)

{

Console.WriteLine("Hello World");

try

{

// Build connection string

SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();

builder.DataSource = "mysqlserver22882.database.windows.net"; // update me

builder.UserID = "azureuser"; // update me

builder.Password = "Christian25!"; // update me

builder.InitialCatalog = "mySampleDatabase"; // update me

// Connect to SQL

Console.Write("Connecting to SQL Server ... ");

using (SqlConnection connection = new SqlConnection(builder.ConnectionString))

{

connection.Open();

Console.WriteLine("Connection Successful.");

}

}

catch(Exception e)

{

// Print the error, if connection failed

Console.WriteLine("Connection Error: " + e.Message);

}

Console.ReadKey();

}

}

}

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

Programming The Perl DBI Database Programming With Perl

Authors: Tim Bunce, Alligator Descartes

1st Edition

1565926994, 978-1565926998

More Books

Students also viewed these Databases questions

Question

What about leadership lessons from particularly good or bad bosses?

Answered: 1 week ago