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 8784847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:12:27+00:00 2026-06-13T21:12:27+00:00

I am stupidly new to VB.. I have my Class ( dalv1 ) where

  • 0

I am stupidly new to VB.. I have my Class (dalv1) where all my functions are stored and my Main Form.

Code is as follows:

Public Sub getCustomerDetails()

        Try
            Dim cust_dataTable As New DataTable()
            Dim Connection As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source = C:\Users\Public\Documents\VP - A1\Database\Database.mdb"
            Dim SQL As String = ("SELECT * FROM tblCustomers")
            Dim dataAdapter As New OleDbDataAdapter(SQL, Connection)
            dataAdapter.Fill(cust_dataTable)
            dataAdapter.Dispose()

        Catch ex As Exception
            MsgBox("ERROR : " & ex.Message.ToString)
        End Try

End Sub

I want to pass the DataTable, cust_dataTable to the Main Form so I can populate text boxes when the form loads.

  • 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-13T21:12:28+00:00Added an answer on June 13, 2026 at 9:12 pm

    You need to turn it into a function so that the table gets returned to the caller:

    Public Function getCustomerDetails() As DataTable
      Dim cust_dataTable As New DataTable()
      Try
        Dim Connection As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source = C:\Users\Public\Documents\VP - A1\Database\Database.mdb"
        Dim SQL As String = ("SELECT * FROM tblCustomers")
        Dim dataAdapter As New OleDbDataAdapter(SQL, Connection)
        dataAdapter.Fill(cust_dataTable)
        dataAdapter.Dispose()        
      Catch ex As Exception
        MsgBox("ERROR : " & ex.Message.ToString)
      End Try
    
      Return cust_dataTable
    End Function
    

    You didn’t share your form’s code, but here is an example of how you would call it:

    Private da As New dalv1
    Private _MyDataTable As DataTable
    
    Protected Overrides Sub OnLoad(ByVal e As EventArgs)
      MyBase.OnLoad(e)
      _MyDataTable = da.getCustomerDetails
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is probably something really stupidly simple.. I have a drop down list bound
Ok my HTML markup is as follows: <div class=refine_search_box> <div class=heading>Refine Search</div> <div class=section_heading><a
I made this stupidly simple PHP file containing <?php class stuff { private $var;
My OOB app was working fine. I stupidly renamed all my namespaces and my
Following on from a previous question, I have the following code: var results =
Ok while watching a tutorial I stupidly missed the part that you have to
I have a simple sql query adding a new row to a database and
I have a set of classes which all take part in an inheritance chain,
I've just launched a new iPhone app and stupidly built it for 3.1.3 only
According to : http://code.google.com/apis/ajaxsearch/documentation/#fonje I get back a cursor result, but stupidly, the moreResultsUrl

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.