How to assign dialog control types to database fields in Data Sources Window

Michael Tadyshak 80 Reputation points
2024-02-14T05:21:03.7666667+00:00

I have a Winforms app connected to a SQL database. In a tutorial I am working through from 3 years ago they have the Data Sources window open with the Customer table at the top followed by Address, City, etc data fields. It shows right clicking any of those items and a list of toolbar items appears from which to choose. With Visual Studio Community 2022 that functionality is not implemented. So how then do I assign data source fields to dialog controls? In which kind of file should those definitions be coded?

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,884 questions
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,671 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Jiale Xue - MSFT 44,501 Reputation points Microsoft Vendor
    2024-02-14T09:25:31.11+00:00

    Hi @Michael Tadyshak , Welcome to Microsoft Q&A,

    First check whether what you created is a .Framework project.

    Regarding the case where Model is not used, database strings are generally used directly for connection.and bind manually using code.

    Similar tutorials are:https://learn.microsoft.com/en-us/visualstudio/data-tools/create-a-simple-data-application-by-using-adonet?view=vs-2022&tabs=csharp

    Best Regards,

    Jiale


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".  Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Karen Payne MVP 35,401 Reputation points
    2024-02-16T10:59:46.63+00:00

    What you have in that tutorial works for .NET Framework 4.8 and lower and with that does not work for .NET Core Framework.

    Option 1

    Although not as easy as what you have seen for the Data Sources window I would recommend using Dapper.

    • Dapper is free
    • Dapper requires less code than what is shown with all tutorials without Dapper.
    • Unlike conventional methods which uses DataSet/DataTable, Dapper uses classes

    Option 2

    Look at EF Core along with EF Power Tools (free) to work with your data.

    Which is better, Dapper or EF Core? For just starting out I would recommend EF Core. For the experienced developer like myself, I use both as there are times when Dapper is better than EF Core. Also, its possible to use both in the same project.

    Here is an EF Core starter project. Here is a Dapper starter project.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.