The target from this project is to know the following:

  1. How to make update, select, delete, select using LINQ to SQL.
  2. How to navigate between records using BindingSource Control.

Mapping Tables to Classes:

  • Attach or create database and create a new Windows Application Project.
  • Then right click on your project name inside Solution Explorer and choose Add > New Item option.
  • You will see the following Add New Item dialog box on your screens.
  • Click the Data category on the left hand side and select LINQ to SQL Classes template from the available templates list.
  • Give the file same name as the database as Ahmed.dbml in my case and click the Add button.

  • The Object Relational Designer appears inside Visual Studio asking you to create data classes by dragging items from Server Explorer or Toolbox to the design surface.
  • You need to add a database connection inside Server Explorer to drag database tables to the designer.
  • Make sure your Server Explorer is visible and if your Server Explorer is not visible go to View menu and click Server Explorer. Inside Server Explorer right click on Data Connections and click Add Connection option.
  • You will see Add Connection dialog box appearing on screen asking you information about your data source.

Code Steps:

  1. LinqSQL3.gif

  2. LinqSQL4.gif

  3. LinqSQL5.gif

  4. Inserting a single record

  5. Deleting Records

  6. Updating Records


    Navigation between Records




Similar Articles