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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:13:32+00:00 2026-05-31T09:13:32+00:00

I am very new to VB.net and I am finding it exceptionally difficult to

  • 0

I am very new to VB.net and I am finding it exceptionally difficult to pass an sql query result (string) into a variable.

No matter what I try, I can’t seem to get anything but boolean output from my reader function.

I need to obtain staff “account type” from my staff table and then define that account type in a variable.

Any suggestions?

Thanks.

  • 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-05-31T09:13:33+00:00Added an answer on May 31, 2026 at 9:13 am

    Here is a good tutorial about using MySQL and VB together:

    • http://zetcode.com/databases/mysqlvisualbasictutorial/

    The piece from this that may be of interest to you:

    Sub Main()
    
        Dim cs As String = "Database=testdb;Data Source=localhost;" _
            & "User Id=testuser;Password=test623"
    
        Dim conn As New MySqlConnection(cs)
    
        Try
            conn.Open()
            Dim stm As String = "SELECT * FROM Authors"
            Dim cmd As MySqlCommand = New MySqlCommand(stm, conn)
            Dim reader As MySqlDataReader = cmd.ExecuteReader()
    
            While reader.Read()
                Console.WriteLine(reader.GetInt32(0) & ": " _ 
                    & reader.GetString(1))
            End While
    
            reader.Close()
    
        Catch ex As MySqlException
          Console.WriteLine("Error: " & ex.ToString())
        Finally
          conn.Close()
        End Try
    
    End Sub
    

    Note the MySqlDataReader (reader) object. This lets you get various types of data back. You need to know the column type you are reading, and use the appropriate method.

    For example if you’re reading a boolean, you would write:

    reader.GetBoolean(0)
    

    Or a DateTime:

    reader.GetDateTime(0)
    

    This example uses int arguments to represent the column number, but I find this less intuitive than using the column name. Fortunately MySqlDataReader supports column names as well:

    reader.GetString("account_type")
    

    The example doesn’t show reading these values into variables, but it’s fairly trivial:

    Dim accountType As String
    ...
    accountType = reader.GetString("account_type")
    

    (This assumes that your account type column is a string.)

    Hopefully this helps get you on the right track.

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

Sidebar

Related Questions

Im very new to SQL but need to write a query to do the
I am VERY new to ASP.NET. I come from a VB6 / ASP (classic)
I am relatively new to ASP.NET MVC, and am very impressed with the clarity
I'm very new to .Net C# and I really don't have a clue as
I'm very new to ASP.net, and I had to fix a issue in and
I'm working on my first asp.net/web development application. Obviously, I'm very new to asp.net
Summary: When attempting to use marshalling to pass string data into a C++ DLL
I very new to .NET and Entity Framework, and I have a problem with
I'm very new to .Net and WPF and have a problem. The code is
I'm very new to lucene.net. I wrote this simple console app in C# which

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.