<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Timothytnk</title>
    <description>The latest articles on DEV Community by Timothytnk (@timcsharp).</description>
    <link>https://dev.to/timcsharp</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1049443%2F3d8455ee-6e02-4779-bbc0-ad541a035e53.png</url>
      <title>DEV Community: Timothytnk</title>
      <link>https://dev.to/timcsharp</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/timcsharp"/>
    <language>en</language>
    <item>
      <title>How to create a simple Student Management Software with Visual Studio 2022 and Microsoft SQL Server 2022</title>
      <dc:creator>Timothytnk</dc:creator>
      <pubDate>Wed, 22 Mar 2023 08:43:56 +0000</pubDate>
      <link>https://dev.to/timcsharp/how-to-create-a-simple-student-management-software-with-visual-studio-2022-and-microsoft-sql-server-2022-35c8</link>
      <guid>https://dev.to/timcsharp/how-to-create-a-simple-student-management-software-with-visual-studio-2022-and-microsoft-sql-server-2022-35c8</guid>
      <description>&lt;p&gt;This guide is for demonstrating how to use &lt;strong&gt;Visual Studio 2022&lt;/strong&gt;  and &lt;strong&gt;Microsoft SQL Server 2022&lt;/strong&gt; to create a new Windows Forms Application that let's you manage student records stored in a Microsoft SQL Server database environment. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;The first step is to make sure you have Visual Studio Software development tool, you can download either the Professional or Community versions from the official Microsoft Visual Studio &lt;a href="https://visualstudio.microsoft.com/downloads/" rel="noopener noreferrer"&gt;website&lt;/a&gt;.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5m6wawbzdbovgtedhuy9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5m6wawbzdbovgtedhuy9.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The second step is to make sure you have &lt;strong&gt;Microsoft SQL Server 2022&lt;/strong&gt; installed and you can download it from the official Microsoft SQL Server &lt;a href="https://www.microsoft.com/en-us/sql-server/sql-server-downloads" rel="noopener noreferrer"&gt;website&lt;/a&gt;. Choose the Developer edition and hit the download option. Run the installer once the download is complete and you should see the window below. &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1oiuoj00neml3mur75kj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1oiuoj00neml3mur75kj.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Choose &lt;strong&gt;basic&lt;/strong&gt; and accept the &lt;strong&gt;Terms and Conditions&lt;/strong&gt; in the next window that shows up which should be similar to the window below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgxvqebchbcqdeva6jl3o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgxvqebchbcqdeva6jl3o.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
After you have accepted the terms and conditions you will be prompted to confirm the &lt;strong&gt;location&lt;/strong&gt; you would like to install the program in the next screen.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkpdm2i4b2ej4rtztk920.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkpdm2i4b2ej4rtztk920.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
After you have specified the location where you would like Microsoft SQL Server to be installed then you will see a progress bar for the installation process in the next screen, wait for the installation to finish.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzb0aisev8ph3lelgvsej.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzb0aisev8ph3lelgvsej.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After Microsoft SQL Server has finished installing then you will see the Setup Successful screen with very important information you can use for establishing a connection to the database from the Windows Forms application.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi9y055xuxzjoeatgnypq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi9y055xuxzjoeatgnypq.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
In the above screen you can see the Text Box labeled as &lt;strong&gt;Connection String&lt;/strong&gt; click on the &lt;strong&gt;clipboard icon&lt;/strong&gt; next to it to &lt;strong&gt;copy&lt;/strong&gt; the connection string and save it to a text file using Notepad or any other relevant text editing tool.&lt;br&gt;
Close the SQL Server 2022 installer window by clicking the button labeled &lt;strong&gt;Close&lt;/strong&gt; at the bottom of the screen.&lt;/p&gt;
&lt;h2&gt;
  
  
  How to create a new Project in Visual Studio 2022
&lt;/h2&gt;

&lt;p&gt;Launch Visual Studio 2022 and you should see the Visual Studio screen launcher which looks similar to the screenshot below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fajip5u4hycazwamn9oga.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fajip5u4hycazwamn9oga.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Then the Window with the options to either &lt;strong&gt;Create  New project&lt;/strong&gt; or &lt;strong&gt;Open an existing Project&lt;/strong&gt; will show up&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb2vfxj61s214pmcw1ytg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb2vfxj61s214pmcw1ytg.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
From the above window click on &lt;strong&gt;Create New Project&lt;/strong&gt; and &lt;br&gt;
you should see a window with &lt;strong&gt;Combo box&lt;/strong&gt; options to specify the &lt;strong&gt;Programing Language&lt;/strong&gt; , &lt;strong&gt;Operating System&lt;/strong&gt; and the &lt;strong&gt;Platform&lt;/strong&gt; the project is targeting. The window should look like similar to the screenshot attached below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj44bw9sg5v7gbsgm8zwr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj44bw9sg5v7gbsgm8zwr.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
From the above window click on the &lt;strong&gt;Programming Language&lt;/strong&gt; Combo box and select &lt;strong&gt;C#&lt;/strong&gt; then click on the next Combo box to choose &lt;strong&gt;Windows&lt;/strong&gt; as the &lt;strong&gt;Operating System&lt;/strong&gt; targeted and finally click on the last Combo box and set the platform targeted to be &lt;strong&gt;Desktop&lt;/strong&gt;. You will see the &lt;strong&gt;templates list&lt;/strong&gt; dynamically updating itself to list all those templates that fit the criteria you specified above. Several templates such as &lt;strong&gt;Windows Forms App, WPF App, WPF Class Library, WPF User Control Library, WPF Custom Control Library et cetera&lt;/strong&gt; will be listed similar to the output shown below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcguecyua8r2pxh42xblt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcguecyua8r2pxh42xblt.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Click on the &lt;strong&gt;Windows Forms App&lt;/strong&gt; template on the screen above and then click on &lt;strong&gt;Next&lt;/strong&gt; to view the Window that let's you specify the &lt;strong&gt;Name of the Project&lt;/strong&gt; and the &lt;strong&gt;Location&lt;/strong&gt; you would like to save the project.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdlbgj5g28bgqiajno4n5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdlbgj5g28bgqiajno4n5.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
From the window above type the Name (&lt;em&gt;mandatory&lt;/em&gt;) of the project as you please and you can also(&lt;em&gt;optional&lt;/em&gt;) choose where you would like to save the project. Click on Next to bring up the Window that should let you choose the &lt;strong&gt;.NET Framework&lt;/strong&gt; you would like to work with.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F69tg0qjbzdi46e5q77nb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F69tg0qjbzdi46e5q77nb.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
While in the Window above you can either choose &lt;strong&gt;.NET 6.0(Long Term Support)&lt;/strong&gt; or &lt;strong&gt;.NET 7.0(Standard Term Support)&lt;/strong&gt;, click on &lt;strong&gt;Create&lt;/strong&gt; to load the new Project in Visual Studio 2022.&lt;/p&gt;
&lt;h2&gt;
  
  
  Using the Designer to add User Interface Controls
&lt;/h2&gt;

&lt;p&gt;After the project is successfully created and loaded into Visual Studio 2022 then you should see the &lt;strong&gt;Designer&lt;/strong&gt; open as a tab in Visual Studio. The designer window looks similar to the output shown below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8x7rjshvdhnhg9hioytk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8x7rjshvdhnhg9hioytk.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
While in the above Window you can click on &lt;strong&gt;View-&amp;gt;Toolbox&lt;/strong&gt; or simply type the keyboard shortcut &lt;strong&gt;Ctrl + Alt + X&lt;/strong&gt; to show the &lt;strong&gt;Toolbox&lt;/strong&gt; that will be useful for adding &lt;strong&gt;Text Box&lt;/strong&gt; elements that will help us in capturing student information from a user using the application. After pressing the keyboard shortcut above then you should see the Toolbox exposed similar to the output shown below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1qtc5yotnk8d85wpir94.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1qtc5yotnk8d85wpir94.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
You can also search for a control by typing in the search box at the top of the Toolbox like in the screenshot attached below. I have searched for the control &lt;strong&gt;Label&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ypipsc2xz0t692cuw1v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ypipsc2xz0t692cuw1v.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Click on a &lt;strong&gt;Label&lt;/strong&gt; control from the &lt;strong&gt;Toolbox&lt;/strong&gt; and move the &lt;strong&gt;cursor&lt;/strong&gt; back to the form designer, the cursor should look like a &lt;strong&gt;cross hair&lt;/strong&gt;. Click on the Form and the control should be generated on the form like in the screenshot below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6f8iodlglgl4iqp2rxyu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6f8iodlglgl4iqp2rxyu.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Click&lt;/strong&gt; on the Label control above and &lt;strong&gt;right click&lt;/strong&gt; on it to show a context menu similar to the screenshot output below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz4b3yzruf9levmrkjrfb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz4b3yzruf9levmrkjrfb.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Click&lt;/strong&gt; on &lt;strong&gt;Properties&lt;/strong&gt; to show the &lt;strong&gt;Properties Window&lt;/strong&gt; of the &lt;strong&gt;Label&lt;/strong&gt; similar to the screenshot attached below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fee5oplai9em5lth3yyt7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fee5oplai9em5lth3yyt7.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Locate the &lt;strong&gt;Text property&lt;/strong&gt; of the Label control from the &lt;strong&gt;Properties&lt;/strong&gt; window highlighted above and change its value to be &lt;em&gt;Student First Name&lt;/em&gt;. After changing the property hit &lt;strong&gt;Enter&lt;/strong&gt; on the keyboard, it should be similar to the output shown below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuvmw2qf290hyxy63vuxd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuvmw2qf290hyxy63vuxd.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Hit the keyboard shortcut &lt;strong&gt;Ctr + Alt + X&lt;/strong&gt; to show the &lt;strong&gt;Toolbox&lt;/strong&gt;, type &lt;strong&gt;Textbox&lt;/strong&gt; in the search bar and click on the &lt;strong&gt;TextBox Control&lt;/strong&gt; to copy it and then move the cursor back to the form designer and click on the area below the first label we created, it should automatically generate the Textbox like shown in the output shown below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feafv4q7cyzg8wjrtd6cc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feafv4q7cyzg8wjrtd6cc.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
The Textbox is generated below the first label, You can drag it and place it to the right of our Label so that the design is similar to the output below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Favhvh4hi0wjh5uclknl8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Favhvh4hi0wjh5uclknl8.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
You can always resize the Form by dragging the edges of the for either vertically or horizontally to increase the width and height respectively. To do this click on the little white boxes on the edges of the Form and drag them &lt;strong&gt;right, left or down&lt;/strong&gt; to increase the size of the form.  See attached screenshot for details on locating those  squares on the designer.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz7o0cki5apdq57cj0tbs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz7o0cki5apdq57cj0tbs.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
After dragging the squares to increase the size of the form you should see an output similar to the screenshot below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5084tf0kmnujqrl4jh7a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5084tf0kmnujqrl4jh7a.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Repeat the same procedure for the  &lt;em&gt;Fields&lt;/em&gt; &lt;strong&gt;Student Last Name, Student Email, Student Phone, Student Address, Student City and Student Nationality&lt;/strong&gt; to have an interface that looks something similar to the screenshot shown below. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4acbfdk0cmxxce336tol.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4acbfdk0cmxxce336tol.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Reopen the Toolbox via the keyboard shortcut &lt;strong&gt;Ctrl + Alt + X&lt;/strong&gt; and search for a &lt;strong&gt;Button&lt;/strong&gt; control and &lt;strong&gt;Drag&lt;/strong&gt; it to the &lt;strong&gt;Form&lt;/strong&gt; to have an interface for the application that looks like below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5ok1ygnoay0xfc749u4q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5ok1ygnoay0xfc749u4q.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Click on the &lt;strong&gt;Button&lt;/strong&gt; control you just added to show the &lt;strong&gt;Properties&lt;/strong&gt; of that Button, find the &lt;strong&gt;Text Property&lt;/strong&gt; and change it to be &lt;strong&gt;Register Student&lt;/strong&gt;, see the screenshot below for more details.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Folnd50cdc1dn5jgjdn4f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Folnd50cdc1dn5jgjdn4f.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
You will notice that when you update the Text property of the button from the Properties window then the text inside the Button in the Form also changes.&lt;br&gt;
Save all the changes made by hitting &lt;strong&gt;Ctrl + S&lt;/strong&gt;&lt;br&gt;
Add a Menu Strip to the top of the Form which will contain the commands to &lt;strong&gt;Edit, Retrieve and Delete&lt;/strong&gt; Student information from the database. To add a Menu Strip to the form hit the keyboard shortcut (&lt;em&gt;Ctrl + Alt + X&lt;/em&gt;) to show the Toolbox and then type &lt;strong&gt;MenuStrip&lt;/strong&gt; in the search bar, click on it and drag it to the designer. You can also just click it then release the mouse button then move the cursor to the designer and click on an empty area on the designer and the menu strip will be autogenerated on the form.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc3nf20y6oz56gfhiacv6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc3nf20y6oz56gfhiacv6.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Click on the above control, release the mouse and once again click on the designer to generate the control on the form. You should expect to see an output like the one in the screenshot below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffub2drtt3lqf6que6o2u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffub2drtt3lqf6que6o2u.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Click on the &lt;strong&gt;menuStrip1&lt;/strong&gt; item at the bottom of the window labeled with the yellow arrow and you should see an &lt;strong&gt;empty textbox at the top of the form&lt;/strong&gt; where you will need to type the name of the first item of the Menu Strip, after typing the text &lt;strong&gt;Retrieve&lt;/strong&gt; you should see an output that matches the screenshot below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuidmlwu5wlhs4tdm9hkh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuidmlwu5wlhs4tdm9hkh.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Click on the &lt;strong&gt;Textbox&lt;/strong&gt; &lt;strong&gt;next&lt;/strong&gt; to the one we just typed the text Retrieve in and type the text &lt;strong&gt;Edit&lt;/strong&gt; so the interface is updated to look like the screenshot below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F82di0pw8c4lzga077e4r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F82di0pw8c4lzga077e4r.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Then click on the &lt;strong&gt;Textbox&lt;/strong&gt; next to the &lt;strong&gt;Edit&lt;/strong&gt; menu strip and add a third menu strip item called &lt;strong&gt;Delete&lt;/strong&gt;. After adding the third menu strip the interface of the app should be updated to look like the screenshot below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhk6ixvingvzoylwmdql1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhk6ixvingvzoylwmdql1.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Save changes by hitting &lt;strong&gt;Ctrl + S&lt;/strong&gt; on the keyboard.&lt;/p&gt;
&lt;h2&gt;
  
  
  Configuring MySQL Server 2022 and connecting it to the Windows Forms App
&lt;/h2&gt;

&lt;p&gt;Since our app needs to read and write the data of these students to and from a database server we have to create a &lt;strong&gt;Database&lt;/strong&gt; called &lt;strong&gt;College&lt;/strong&gt; and a &lt;strong&gt;Table&lt;/strong&gt; called &lt;strong&gt;Students&lt;/strong&gt; in that Database which will store the actual information captured from a student via the interface of the Windows Forms App.&lt;/p&gt;

&lt;p&gt;SQL Server 2022 runs automatically when the device boots and we only need to connect to it from a &lt;strong&gt;Command Line Interface&lt;/strong&gt; and &lt;strong&gt;run all queries&lt;/strong&gt; to create the Databases and Tables.&lt;br&gt;
In order to do that we need to follow the steps below religiously:&lt;/p&gt;

&lt;p&gt;Open &lt;strong&gt;Command Prompt&lt;/strong&gt; and type the following command to connect to SQL Server 2022 remotely.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sqlcmd -S localhost -E&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If the above command is successful then you should see the &lt;strong&gt;path&lt;/strong&gt; on your &lt;strong&gt;Command Line Terminal&lt;/strong&gt; replaced with the text &lt;strong&gt;&amp;gt;1&lt;/strong&gt; like in the screenshot shown below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkudj9xu4rnksy4lucb4e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkudj9xu4rnksy4lucb4e.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After you have connected to the Database Server then you need to run commands to create a new &lt;strong&gt;Database&lt;/strong&gt; named &lt;strong&gt;College&lt;/strong&gt; with the syntax below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE DATABASE College
GO
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the command is successful then you will see a screenshot similar to the one below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff0eiqgmjg2tobp2jp344.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff0eiqgmjg2tobp2jp344.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Create a new &lt;strong&gt;Table&lt;/strong&gt; named &lt;strong&gt;Students&lt;/strong&gt; in the same &lt;strong&gt;College&lt;/strong&gt; Database with the columns for &lt;strong&gt;student_id, student_fname, student_lname, student_phone, student_address, student_city and student_nationality&lt;/strong&gt; with the syntax below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;USE College;
CREATE TABLE Student (
    student_id INT IDENTITY(1,1) PRIMARY KEY,
    first_name VARCHAR(50),
    last_name VARCHAR(50),
    phone VARCHAR(20),
    address VARCHAR(100),
    city VARCHAR(50),
    nationality VARCHAR(50)
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After running the command above successfully then the terminal will show a new line for you to type in the next command like in the screenshot below.&lt;/p&gt;

&lt;p&gt;Now go back to the Form Designer and double click on the &lt;strong&gt;Form&lt;/strong&gt; and on a section on the form with no controls for example you could double click on the section with the red spot like in the screenshot below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2te5ebftd6pll5vw3fz2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2te5ebftd6pll5vw3fz2.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
After you have clicked on the red spot shown in the screenshot above then the IDE will autogenerate a method that gets invoked when the form is loaded. The method signature takes after the method called **** on the screenshot below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbz11f7b43i0i1xlvg0s6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbz11f7b43i0i1xlvg0s6.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
In that method we are going to write &lt;strong&gt;C#&lt;/strong&gt; source code that connects to the SQL Server Database and shows a Message Box alert if the connection was successful.&lt;br&gt;
Open the text file where you saved the &lt;strong&gt;connection string&lt;/strong&gt; and copy the connection string by clicking &lt;strong&gt;Ctrl + C&lt;/strong&gt;. If you didn't save the connection string to a text file then you can copy it from the screenshot below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyszwb9ajrctbkvy3l848.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyszwb9ajrctbkvy3l848.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Copy the above connection string then double click on the Form to open the method handler for the Form's &lt;strong&gt;OnLoad&lt;/strong&gt; event handler , migrate to the top of the class and add a definition called &lt;strong&gt;connectionString&lt;/strong&gt; like shown in the screenshot below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv9buhkyiap4709pe8r24.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv9buhkyiap4709pe8r24.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Scroll Down and place the cursor inside the method with the signature &lt;strong&gt;private void Form1_Load(object sender, EventArgs e){}&lt;/strong&gt; and place the following code in it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;try
    {
        using (SqlConnection connection = new SqlConnection(connectionString))
        {
            connection.Open();
            MessageBox.Show("Connection successful!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
    }
    catch (Exception ex)
    {
        MessageBox.Show("Connection failed. Error message: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After pasting the code you should see an output similar to the screenshot below where the type &lt;strong&gt;SqlConnection&lt;/strong&gt; shows a compile time error. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbqmicz9a2dy3wmz6miji.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbqmicz9a2dy3wmz6miji.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
To remove the error above, Hit the keyboard shortcut &lt;strong&gt;Ctrl + Enter&lt;/strong&gt; and you should see an option named &lt;em&gt;Install Package System.Data.SqlClient&lt;/em&gt; that corresponds the screenshot below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwoe2uu2c085xswu5nvnb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwoe2uu2c085xswu5nvnb.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
From the screenshot above, choose &lt;em&gt;Install Package System.Data.Client&lt;/em&gt; and then  choose &lt;em&gt;Find and Install The Latest version&lt;/em&gt;&lt;br&gt;
which should find and install the &lt;em&gt;System.Data.SqlClient&lt;/em&gt; into the project. This will get rid of the error so that the final state of the code in the Form is like in the screenshot below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4nuzsdss44awgkyn3d5p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4nuzsdss44awgkyn3d5p.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Debugging the Program
&lt;/h2&gt;

&lt;p&gt;In order for us to test if the program is working as expected, we need to use the &lt;strong&gt;Debug Button&lt;/strong&gt; to &lt;strong&gt;Run&lt;/strong&gt; the program. You can always find the &lt;strong&gt;Debug&lt;/strong&gt; option at the top of the window as a &lt;strong&gt;green  rotated triangle&lt;/strong&gt; pointing to the right and it's highlighted in the screenshot below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxyucs8jnexn36micl98h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxyucs8jnexn36micl98h.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Click on one of the two green triangles in the screen above to run the program and you should get an output similar to the screenshot below where the connection to SQL Server Database is successful.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkjgc4onbwc2cx17pn4kh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkjgc4onbwc2cx17pn4kh.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
The info in screenshot above shows that the program is now &lt;strong&gt;connected&lt;/strong&gt; to SQL Server successfully.&lt;br&gt;
Click on &lt;strong&gt;OK&lt;/strong&gt; on the Message Dialog in the dialog above to clear it so that the form application is shown like in the screenshot below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyucxvibsnf8w0gyfin7d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyucxvibsnf8w0gyfin7d.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Close the Form and click the &lt;strong&gt;Form1.cs&lt;/strong&gt; file in the Solution Explorer, &lt;strong&gt;Right Click&lt;/strong&gt; on it and choose &lt;strong&gt;View Designer&lt;/strong&gt;. The step is clearly highlighted in the screenshot below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fum57a7j1g4c8mtdbsvyq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fum57a7j1g4c8mtdbsvyq.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
On the Designer double click on the &lt;strong&gt;Register Student&lt;/strong&gt; button and the code for handling &lt;strong&gt;Click Events&lt;/strong&gt; for this button should be generated in similar output to the screenshot below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6fkxwzupkwdkpu3j2fnr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6fkxwzupkwdkpu3j2fnr.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Validating User Input On the Form
&lt;/h2&gt;

&lt;p&gt;Since the program requires the Textbox fields on the program to be filled, we need logic in the event handler of the button to check if the user tries to submit empty fields and prompt him/her to enter the correct values. For example the Student First Name field has some few rules like &lt;strong&gt;Name should not be less than three characters, Name should not contain Numbers or Special Characters, Name should not be empty&lt;/strong&gt;. To achieve this we have the reference of the Textbox as &lt;strong&gt;textbox1&lt;/strong&gt;, we add C# code into the button handler that will make sure those conditions are met. Sample code is shown below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;string input = textBox1.Text;
    if (input. Length &amp;lt; 3)
    {
        MessageBox.Show("The text must be at least 3 characters long.", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Warning);
        return;
    }
    else if (string.IsNullOrWhiteSpace(input))
    {
        MessageBox.Show("The text cannot be empty.", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Warning);
        return;
    }
    else if (Regex.IsMatch(input, @"[^a-zA-Z0-9 ]"))
    {
        MessageBox.Show("The text contains special characters.", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Warning);
        return;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After pasting the code above in the &lt;strong&gt;button_1_Click&lt;/strong&gt; event then my code looks like the screenshot attached below.&lt;/p&gt;

&lt;p&gt;After updating the code, Run the program by clicking on the green run button and you should see that when you attempt to click on the &lt;strong&gt;Register Student&lt;/strong&gt; button while the Textbox for Student First Name is empty then the program shows errors for the user to correct. Sample output is shown in the screenshots below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkmjy4stmdvptt1ds4y7y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkmjy4stmdvptt1ds4y7y.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
You can define the validation rules for the other Textbox elements by changing the reference of the code above to include &lt;strong&gt;textBox1, textBox2&lt;/strong&gt; and so on and so forth.&lt;br&gt;
We are now going to insert our first student record into the database and to do that we will write a method that takes the input from the form as parameters and runs a query against the database and returns true if the operation was successful otherwise it will return false if there was a problem or an exception.&lt;br&gt;
The method code is highlighted below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public bool InsertStudentRecord(string firstName, string lastName, string phone, string address, string city, string nationality)
        {
            string query = "INSERT INTO Student (first_name, last_name, phone, address, city, nationality) VALUES (@studentId, @firstName, @lastName, @phone, @address, @city, @nationality);";

            try
            {
                using (SqlConnection connection = new SqlConnection(connectionString))
                {
                    connection.Open();
                    SqlCommand command = new SqlCommand(query, connection);
                    command.Parameters.AddWithValue("@firstName", firstName);
                    command.Parameters.AddWithValue("@lastName", lastName);
                    command.Parameters.AddWithValue("@phone", phone);
                    command.Parameters.AddWithValue("@address", address);
                    command.Parameters.AddWithValue("@city", city);
                    command.Parameters.AddWithValue("@nationality", nationality);
                    int result = command.ExecuteNonQuery();

                    if (result &amp;gt; 0)
                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return false;
            }
        }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open the &lt;strong&gt;Form1.cs&lt;/strong&gt; file and paste the method above into it so that the code file is updated to look something similar to the screenshot below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdy3vzdsvqifjkwaapu73.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdy3vzdsvqifjkwaapu73.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Scroll to the method that handles the events for our Register Student button and use the method we pasted above in a conditional structure similar to the code highlighted below&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;private void button1_Click_1(object sender, EventArgs e)
        {
            string input = textBox1.Text;

            if (input.Length &amp;lt; 3)
            {
                MessageBox.Show("The text must be at least 3 characters long.", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            else if (string.IsNullOrWhiteSpace(input))
            {
                MessageBox.Show("The text cannot be empty.", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            else if (Regex.IsMatch(input, @"[^a-zA-Z0-9 ]"))
            {
                MessageBox.Show("The text contains special characters.", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            } 
            //Validation for other Input fields
            //if everything works as expected then get student details

            //get the first name of the student
            var fname = textBox1.Text;
            //get the last name of the student
            var lname = textBox2.Text;
            //get the contact of the student
            var phone = textBox3.Text;
            //get the address of the student
            var address = textBox4.Text;
            //get the city of the student
            var city = textBox5.Text;
            //get the nationality of the student
            var nation = textBox6.Text;
            if (InsertStudentRecord(fname, lname, phone, address, city, nation))
            {
                MessageBox.Show("Student record inserted successfully into the database");
            }
            else {
                MessageBox.Show("Insert operation failed, check exception for details");

            }
        }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run the program and make sure you fill all the fields and then click on the &lt;strong&gt;Register Student&lt;/strong&gt; button.&lt;br&gt;
If you have done everything correctly then the program should be successful and will show an alert that the Student information was inserted into database successfully. See screenshot below for more details.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6fgncnn2h17039ui11mq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6fgncnn2h17039ui11mq.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Now open the designer to view the Menu Strip items &lt;strong&gt;Retrieve, Edit and Delete&lt;/strong&gt;. The opened designer will take after the screenshot below. &lt;strong&gt;Double Click&lt;/strong&gt; on the Menu Strip item labeled &lt;strong&gt;Retrieve&lt;/strong&gt; which is pointed at by an orange arrow.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9q7kozfy8l6yej302jbb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9q7kozfy8l6yej302jbb.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
After double clicking on the &lt;strong&gt;Retrieve&lt;/strong&gt; menu strip item then the IDE will generate a method that will enable us to program the &lt;strong&gt;Click&lt;/strong&gt; event for that particular menu strip. We need to program this menu strip item to accept a student ID from the user and returns a list of data about that student from database. The method is generated and shown in a similar fashion to the screenshot below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft26xr1qnyj0vzx0dxrsp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft26xr1qnyj0vzx0dxrsp.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
We need to capture  &lt;strong&gt;student_id&lt;/strong&gt; information from the user so that we can use it to retrieve all the information about the student with that &lt;strong&gt;student_id&lt;/strong&gt; from database , we will show an Input Dialog to prompt the user to enter the student ID using the code below. Paste the code below in the method shown in the screenshot above.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var studentID = Microsoft.VisualBasic.Interaction.InputBox("Please enter your student ID:", "Enter Student ID");
            //check if the user did not enter anything or a non number literal
            var empty = studentID == string.Empty;
            if (empty)
            {
                //user did not enter student ID, show a message box explainging why
                MessageBox.Show("The student ID is required to be able to retrieve information about that student");
                //do not execute further code
                return;
            }
            else
            {
                //check if the user did enter something but a non integer literal
                if(Int32.TryParse(studentID, out int result))
                {
                    //user entered the correct input
                    //get the integer and query for all the information for that student from database

                }
                else
                {
                    //user entered a an incorrect input
                    MessageBox.Show("You entered an incorrect integer literal");
                    return;
                }
            }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After pasting the above code in the &lt;strong&gt;retrieveToolStripMenuItem_Click&lt;/strong&gt; method then the user is prompted to enter the student ID when he clicks on the item.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd407egokuprzon1b1llk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd407egokuprzon1b1llk.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
We will write another method that takes an integer argument as student ID, queries the database for all the information about that student and returns a List of data about that student. The method signature is shown in the screenshot below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public List&amp;lt;string&amp;gt; GetStudentData(string studentId)
        {
            // Set up a connection to your database
            SqlConnection connection = new SqlConnection(connectionString);
            // Create a SQL query that selects all columns from a table called "students"
            // where the "id" column matches the specified studentId.
            string query = "SELECT * FROM student WHERE studet_id = @studentId";
            SqlCommand command = new SqlCommand(query, connection);
            command.Parameters.AddWithValue("@studentId", studentId);

            // Open the connection to the database and execute the query.
            connection.Open();
            SqlDataReader reader = command.ExecuteReader();

            // Read the data returned by the query and add each column's value to a list of strings.
            List&amp;lt;string&amp;gt; studentData = new List&amp;lt;string&amp;gt;();
            while (reader.Read())
            {
                studentData.Add(reader["id"].ToString());
                studentData.Add(reader["name"].ToString());
                studentData.Add(reader["age"].ToString());
                studentData.Add(reader["major"].ToString());
                // Add more columns here as needed.
            }

            // Close the reader and the connection to the database.
            reader.Close();
            connection.Close();

            // Return a tuple containing the student data list and the count of the list.
            return studentData;
        }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Paste the code in your &lt;strong&gt;Form1.cs&lt;/strong&gt; file so that it is nested inside the class like shown in the screenshot below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhgvvvcdxwk3zty54rt56.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhgvvvcdxwk3zty54rt56.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After pasting the code inside your class then update your &lt;strong&gt;retrieveToolStripMenuItem_Click&lt;/strong&gt; handler to look like below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;private void retrieveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var studentID = Microsoft.VisualBasic.Interaction.InputBox("Please enter your student ID:", "Enter Student ID");
            //check if the user did not enter anything or a non number literal
            var empty = studentID == string.Empty;
            if (empty)
            {
                //user did not enter student ID, show a message box explainging why
                MessageBox.Show("The student ID is required to be able to retrieve information about that student");
                //do not execute further code
                return;
            }
            else
            {
                //check if the user did enter something but a non integer literal
                if(Int32.TryParse(studentID, out int result))
                {
                    //user entered the correct input
                    //get the integer and query for all the information for that student from database\
                    var data = GetStudentData(studentID);
                    if (data.Count == 0)
                    {
                        //no student was found with that ID
                        MessageBox.Show("No student with such ID exists in the database");
                        return;
                    }
                    if(data.Count &amp;gt;0)
                    {
                        //build a student info string
                        var info = "Names: " + data[0] + " " + data[1] + "\n" +
                            "Phone: " + data[2] + "\n" +
                            "Address: " + data[3] + "\n" +
                            "City: " + data[4] + "\n" + "\n" +
                            "Nationality: " + data[5];
                        MessageBox.Show(info,"Student Found");
                    }
                }
                else
                {
                    //user entered a an incorrect input
                    MessageBox.Show("You entered an incorrect integer literal");
                    return;
                }
            }
        }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run the program, click on &lt;strong&gt;Retrieve&lt;/strong&gt; and pass &lt;strong&gt;1&lt;/strong&gt; as the studentID parameter and click &lt;strong&gt;OK&lt;/strong&gt; to view information about the student with that ID.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgvwad90xtvsadskuvok1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgvwad90xtvsadskuvok1.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
If you inserted a student record into the database then this operation should be successful and you should see a message box with the student information similar to the screenshot below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fova3t2360nmpguarr2bd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fova3t2360nmpguarr2bd.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Open the &lt;strong&gt;Designer&lt;/strong&gt; by clicking on the file &lt;strong&gt;Form1.cs[Design]*. **Double Click&lt;/strong&gt; the &lt;strong&gt;Edit&lt;/strong&gt; menu strip item at the top of the window, the menu strip item to double click is pointed at with the orange  arrow in the screenshot below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgv1kutc004j7t8o4jeq8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgv1kutc004j7t8o4jeq8.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
After double clicking on the menu strip above you should be able to see a method that has been generated by the IDE for handling the click events made on the &lt;strong&gt;Edit&lt;/strong&gt; menu strip item. The method should be similar to the screenshot below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5wg7xdev85brjdklvz99.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5wg7xdev85brjdklvz99.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
We will place code in that method that will also require the student ID parameter from the user and then shows input dialog with the title for each property of that record that the user intends to edit. The code is highlighted in the code section below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    //display an input dialog for the student ID the user would like to edit
            var studentID = Microsoft.VisualBasic.Interaction.InputBox("Please enter the  student ID you want to edit:", "Enter Student ID");
            //cegck if the input is empty
            var empty = studentID == string.Empty;
            if (empty)
            {
                MessageBox.Show("You have to enter the ID of the student you would like to edit", "Student ID error");
                //do not execute further code
                return;
            }
            else
            {
                //if not empty try and parse an integer literal out of the string
                if(Int32.TryParse(studentID,out var b))
                {
                    //integer parsed legal
                    //check if such a record exists in the database
                    //if true show the input dialog to capture the new values for the student object
                }
                else
                {
                    //integer parsed is illegal
                    MessageBox.Show("The integer literal you entered is invalid");
                }
            }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Paste the code above in the &lt;strong&gt;editToolStripMenuItem_Click&lt;/strong&gt; method  in the &lt;strong&gt;Form1.cs&lt;/strong&gt; file. After that we need to define a Boolean method that will check if a row with the student ID specified for editing purposes exists in the database table then we show a message box if a record is found and show fields for the user to edit the record if the record is found. Code section is shown below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public bool CheckIfRecordExists(string studentId)
        {
            bool recordExists = false;
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                string query = "SELECT COUNT(*) FROM Student WHERE student_id = @studentId";
                SqlCommand command = new SqlCommand(query, connection);
                command.Parameters.AddWithValue("@studentId", studentId);
                connection.Open();
                int count = (int)command.ExecuteScalar();
                if (count &amp;gt; 0)
                {
                    recordExists = true;
                }
                else
                {
                }
            }
            return recordExists;
        }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Paste the code above in the method level of your &lt;strong&gt;Form1.cs&lt;/strong&gt; file. After pasting the method above you should see the file updated to be similar to the output below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpanyrpu1bmk5p28udhni.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpanyrpu1bmk5p28udhni.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Use the method above in the &lt;strong&gt;editToolStripMenuItem_Click&lt;/strong&gt; method and to check if there is an existing database table entry associated with that student ID or not. Here is a screenshot showing how to use the method to check for the record.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnsd2ej6br02clcedgfhx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnsd2ej6br02clcedgfhx.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Run the program, find the &lt;strong&gt;Edit&lt;/strong&gt; menu strip command and click on it, immediately you should be prompted for a student ID parameter entry via an Input Dialog message box as shown in the screenshot below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxr9es87u9uk5vs3ipa4z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxr9es87u9uk5vs3ipa4z.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Pass a sample &lt;strong&gt;student ID&lt;/strong&gt; parameter, in this case I passed the parameter &lt;strong&gt;1&lt;/strong&gt; and clicked on &lt;strong&gt;OK&lt;/strong&gt;. You will see a prompt to edit the first name of the student with the ID you just passed.&lt;br&gt;
I will type the name &lt;strong&gt;Williams&lt;/strong&gt; to update the first name of the record with the &lt;strong&gt;student ID 1&lt;/strong&gt;, I will then click OK and wait for the program to show the message that the &lt;strong&gt;Update&lt;/strong&gt; operation was successful. The screenshot below shows the value I entered for updating the first name of the entry with the student ID parameter &lt;strong&gt;1&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa31apnyzr88u5rvip7dv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa31apnyzr88u5rvip7dv.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>csharp</category>
    </item>
  </channel>
</rss>
