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

  • SEARCH
  • Home
  • 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 9186961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:39:25+00:00 2026-06-17T19:39:25+00:00

I use Visual Basic 2010 and Microsoft SQL Server 2008. I have my database

  • 0

I use Visual Basic 2010 and Microsoft SQL Server 2008. I have my database and my table and i made the connection (at least i think i did) in VB using only the interface.

What i want to know is how to get data from the database and use it into my VB project. I have of course searched for solutions already but the differences i find only confuse me more. What i need to know are the basics, the tools/objects and procedures to retrieve the data.

What i try to do at the moment is make a simple selection and put that data into a listbox right when the program starts, like this:

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        SqlConnection1.Open()



        SqlConnection1.Close()

    End Sub
End Class
  • 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-17T19:39:27+00:00Added an answer on June 17, 2026 at 7:39 pm

    1) Create your connection string

    Dim connectionString As String = "Data Source=localhost;........."
    

    2) Connect to your Database

    Dim connection As New SqlConnection(connectionString)
    conn.Open()
    

    3) Create a Command and the query

    Dim command As New SqlCommand("SELECT * FROM Product", connection)
    Dim reader As SqlDataReader = command.ExecuteReader()  //Execute the Query
    

    4) Retrieve your result. There are several ways

    Dim dt As New DataTable()
    dt.Load(reader)
    
    'Close the connection
    connection.Close()
    

    5) Bind to your list box

    myListBox.ItemSource = dt
    

    Full code here

    Using connection As New SqlConnection(connectionString)
        Dim command As New SqlCommand("Select * from Products", connection)
        command.Connection.Open()
        SqlDataReader reader = command.ExecuteReader()
     End Using
    

    For more info

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

Sidebar

Related Questions

Helo, I have an SQL database, and 50 text files, and Visual Basic 2010
Errors Database administrators report Microsoft SQL Server 2008 server-side error Invalid Login (error 18456,
I have created a program in Visual Basic using Microsoft Visual Studio 2010 Professional.
I want to use excel function in Visual Basic 2010 Express. I tried to
i am very beginner in visual basic and i have 2010 express. i want
I have an error message that occurs every time I use SQL Server 2012
Just recently I've started with Microsoft Visual Basic 2010 Express and I am creating
I am creating a server built in Visual Basic 2010 and that program can
I'm a beginner starting to use Microsoft Visual C++ Express 2010 for Windows Programming.
I don't want use old Visual Basic methods in my code, and I'm confused

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.