Download and install SQL Server Express on your local machine.
https://www.microsoft.com/en-us/sql-server/sql-server-downloadsLinks to an external site.
Here is the installation guide:
MAKE SURE YOU INSTALL SSMS AS PART OF THE SQL SERVER INSTALL.
THIS IS AN INDIVIDUAL ASSIGNMENT.
Next, create the database schemas (write the SQL) for the following table and execute them on your local SQL Server.
Table name: Employee
Fields should be:
EmpID int,
LastName varchar(255),
FirstName varchar(255),
Address varchar(255),
City varchar(255)
https://www.mytecbits.com/microsoft/dot-net/error-sqlconnection-could-not-be-foundLinks to an external site. explains how to update your code reference for System.Data.SqlClient.
Populate the table with dummy data (this will let you test that it actually works). The dummy data does not have to be a large dataset- a couple of rows of data should suffice. Create a console app in C# (you can create any kind of solution, upto you; even a console application is fine).
Once you have made the sln file/project folder: Project -> Manage NuGet Packages…In the search, type System.Data.SqlClient and install it. Do not install Other versions of SqlClient – what you need is System.Data.SqlClient
Create a C# file in your console app and call it ConnectionAccessor.cs. Write one method inside this class and call it TestDatabaseConnection. Utilize a connection string in this method and connect to the database you just created and populated. Print a message to the console when your connection is successful, and take a screenshot of the message. UPLOAD THE FOLLOWING TO THIS ASSIGNMENT:
- Your .cs file containing the code to connect (If you used a web.config file, include that also. If not, just include the .cs file).
- The screenshot of a successful connection
- your SQL script you used to create the table – in a .sql file
Here are code examples:
https://o7planning.org/10511/connect-to-sql-server-database-in-csharpLinks to an external site.
This assignment is worth 50 points in total. 25 for the SQL script and config files, and 25 for the C# code.
Good luck!