How to fix the error (DataSet is empty)

BenTam 1,761 Reputation points
2023-08-06T14:36:37+00:00

Dear All,

Could anyone tell me what is wrong with the following code? (DataSet ds is empty)

enter image description here

However, when I put the code into SSMS, it returns a result.

enter image description here

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,927 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,400 questions
{count} votes

Accepted answer
  1. Jiale Xue - MSFT 49,831 Reputation points Microsoft External Staff
    2023-08-07T06:23:42.3233333+00:00

    Hi @BenTam-3003 , Welcome to Microsoft Q&A,

    From the code point of view, you just created a new dataset.

    Try adding code:

    dataadapter. Fill(ds, "Course_table");

    The data should be added to ds.Tables["Course_table"].

    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.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

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.