Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8811257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:19:05+00:00 2026-06-14T03:19:05+00:00

We are developing an ASP.Net web application with a SQL Server database and would

  • 0

We are developing an ASP.Net web application with a SQL Server database and would like to populate an ASP.Net label control with the total number of students who are enrolled at the school whenever the home page is displayed.

We created the following strongly typed controls with the dataset designer:

DataTable: Students
DataSet: DataSetAllStudents
TableAdapter: StudentsTableAdapter

In the VB.Net code-behind file I used the following code to start the process of obtaining a total count of enrolled students.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    Dim studentsAdapter As New DataSetAllStudentsTableAdapters.StudentsTableAdapter
    Dim studentsTableRow As Knowledge_Academy.Students

    studentsTableRow = studentsAdapter.GetData

End Sub

We get an error on this line of code:

studentsTableRow = studentsAdapter.GetData

This is the error:

Value of type 'Knowledge_Academy.DataSetAllStudents.StudentsDataTable' cannot be 
converted to 'Knowledge_Academy.Students'.

GetData contains the query that will return the total number of enrolled students. We would also like to know how to get the value returned into this ASP.Net label control.

<asp:Label ID="LabelTotalNumberOfStudents" runat="server" Text="Label"></asp:Label>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T03:19:07+00:00Added an answer on June 14, 2026 at 3:19 am

    First, ensure that you load the data only on the first load and not on every postback. Second, since GetData returns a DataTable with all rows you can use it’s Rows.Count property:

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            Dim daStudents = New DataSetAllStudentsTableAdapters.StudentsTableAdapter()
            Dim tblStudents = studentsAdapter.GetData()
            LblStudentNumber.Text = String.Format("{0}", tblStudents.Rows.Count)
        End If
    End Sub
    

    Of course it would be better to add a new query to the TableAdapter that returns a scalar value with the number of students. That would require much less resources.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently developing a web application in ASP.Net with SQL Server and I would
I am developing my first ASP.Net MVC 3 web application against a SQL Server
We are developing a web application using asp.net and sql server. We are required
I am developing one web application using asp.net 2005 and Microsoft SQL Server 2008
I am developing a web Application in ASP.NET 3.5 with SQL Server 2008. I
I am developing a C#/SQL ASP.NET web application in VS 2008. Currently I am
I am developing a C#/SQL ASP.NET web application in VS 2008. I want the
I am developing an ASP.NET web application that sends a request to another server
I am developing a C# VS 2008 / SQL Server 2008 ASP.NET Web Applications
I'm developing an ASP.NET 3.5 WebForms application where I would like the session to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.