In this article we discuss the dynamic connection class in Windows Form application.
Introduction In this article we discuss the dynamic connection class in C# because in the beginner’s level most of students are clear about the inheritance and connection class, but can’t use this dynamic approach in a professional project. Basically object-oriented programming solves many issues and makes our programming much easier. When you read this article you'll have a good knowledge about object-oriented programming. What is the benefit of Dynamic Connection Class?
Step 1: Now we start, first we create the Windows Form Based Project then after choosing Windows Form Project we press OK Button. Step 2: After creating the project we add the class and change the name of the class and set the name as Connection Class. Left click on you project and add class and press add button. Step 3: Now we create the database in Microsoft Access 2013 name as EmployeeDatabase and name the table Employee. Step 4: Now we add a connection string in App.config file you only give the accurate name of your database and nothing else. Step 5: After creating the class we make some method in class then we inherit this method in our program. First we add two namespaces in our program; if you are using Microsoft Access then add these two namespaces in your class. If you are using SQL Server then you add another two libraries which are similar to Microsoft Access -- only change OLEDB to SQL. Step 5: Left click on your reference which is shown in your project and then click on assemblies and add System.Configuration in your project then press Ok button. Step 6: Now we design the user interface to insert the employee information by dragging and dropping some labels and textboxes and buttons Step 6: Now double click on the Save button and now we don't need any open and closed connection we only make instance of class and then use it. Step 7: Now we make the insert query and inherit all methods which we declare in class and use it.
Read more articles on Windows Forms:
Node Js and Angular CheatSheet