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

The Archive Base Latest Questions

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

I’m using the following code in an attempt to retrieve data from two tables

  • 0

I’m using the following code in an attempt to retrieve data from two tables and populate a ComboBox with that information. Then when the user selects a value from the ComboBox, I want to populate all the controls on the form with the data retrieved from the DB that matches the value of the ComboBox (still haven’t figured out how to do this one yet).

NOTE: The 1090 shown in the error is the account number I’m receiving from an InputBox control and then setting the TextboxAccount.Text value to it. So I’m not sure if this is where my problem is.

Here’s the VB exception being thrown:

“You have an error in your SQL syntax; check the manual that
corresponds with your MySQL version for the right syntax to use near
‘customer.accountNumber = ‘1090″ at line 1”

Here’s my code:

    Private Sub RetrieveMySQLdata()

    Try
        'FOR MySQL DATABASE USE
        Dim dbConn As New MySqlConnection
        Dim dbQuery As String = ""
        Dim dbCmd As New MySqlCommand
        'Dim dbData As MySqlDataReader
        Dim dbAdapter As New MySqlDataAdapter
        Dim dbTable As New DataTable
        If dbConn.State = ConnectionState.Closed Then
            'dbConn = New MySqlConnection
            dbConn.ConnectionString = String.Format("Server={0};Port={1};Uid={2};Password={3};Database=accounting", FormLogin.ComboBoxServerIP.SelectedItem, My.Settings.DB_Port, My.Settings.DB_UserID, My.Settings.DB_Password)
            dbConn.Open()
        End If

        dbQuery = "SELECT *" & _
                   "FROM cc_master INNER JOIN customer ON customer.accountNumber = cc_master.customer_accountNumber" & _
                   "WHERE customer.accountNumber = '" & TextBoxAccount.Text & "'"
        With dbCmd
            .CommandText = dbQuery
            .Connection = dbConn
        End With
        With dbAdapter
            .SelectCommand = dbCmd
            .Fill(dbtable)
        End With
        Dim i As Integer
        For i = 0 To dbTable.Rows.Count - 1
            ComboBoxCard.ValueMember = "cc_Number"

        Next
    Catch ex As Exception
        MessageBox.Show("A DATABASE ERROR HAS OCCURED" & vbCrLf & vbCrLf & ex.Message & vbCrLf & _
                    vbCrLf + "Please report this to the IT/Systems Helpdesk at Ext 131.")
    End Try

End Sub
  • 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-12T03:27:17+00:00Added an answer on June 12, 2026 at 3:27 am

    In this statement:

    dbQuery = "SELECT *" & _
              "FROM cc_master INNER JOIN customer ON customer.accountNumber = cc_master.customer_accountNumber" & _
              "WHERE customer.accountNumber = '" & TextBoxAccount.Text & "'"
    

    There’s no space between some of the clauses, such as cc_master.customer_accountNumber and WHERE. The resulting string would read like:

    SELECT *FROM cc_master INNER JOIN customer ON customer.accountNumber = cc_master.customer_accountNumberWHERE customer.accountNumber = 'SOME SQL INJECTABLE STRING'
    

    As a general hint with MySQL syntax error messages, when you see a message like this:

    “You have an error in your SQL syntax; check the manual that corresponds with your MySQL version for the right syntax to use near ‘customer.accountNumber = ‘1090″ at line 1”

    You should look just before the part that it’s “near” to find the syntax error. The query parser reads from beginning to end and throws an error when it finds something it can’t interpret. And usually the first thing it can’t interpret is the first thing it sees after the typo/error.

    Please note also that using string concatenation is a very bad idea for constructing SQL queries. It leaves you wide open to SQL injection attacks. If you’re using plain old ADO.NET, at the very least you should be using parameterized queries. As a step further, you may want to look into something like LINQ to SQL or Entity Framework which abstracts the database access behind auto-generated code which parameterizes for you behind the scenes.

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a view passing on information from a database: def serve_article(request, id): served_article
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

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.