Click here to Skip to main content
15,903,388 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hey guys so i have this code

Private Sub Load_Table()



        MysqlConn = New MySqlConnection
        MysqlConn.ConnectionString = "server=XXXXXXXXX; user id=XXXXXXXX; password=XXXXXX; database=XXXXXXXX"
        Dim SDA As New MySqlDataAdapter
        Dim dbDataSet As New DataTable
        Dim dbSource As New BindingSource



        MysqlConn.Open()
            Dim query As String
        query = "select * From sql12305518." & ComboBox1.Text & ""
        COMMAND = New MySqlCommand(query, MysqlConn)

            SDA.SelectCommand = COMMAND

            SDA.Fill(dbDataSet)
            dbSource.DataSource = dbDataSet
            DataGridView1.DataSource = dbSource
            SDA.Update(dbDataSet)

            DataGridView1.Columns(0).HeaderText = "Code"
            DataGridView1.Columns(1).HeaderText = "PCID"
            DataGridView1.Columns(2).HeaderText = "Assigned_To"
            DataGridView1.Columns(3).HeaderText = "Deployed"

            MysqlConn.Close()



            getstring()



however im receiving an error


MySql.Data.MySqlClient.MySqlException: 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1'

which is pointing out at
SDA.Fill(dbDataSet)


What I have tried:

I cant seem to find what the error is about, can you have a look? maybe a fresh set of eyes will see the error
Posted
Updated 18-Nov-20 19:49pm

You must use a DataSet instead of DataTable:
Dim dbDataSet As New System.Data.DataSet
 
Share this answer
 
We can't help - we have no access to your Combobox or whatever items you have filled it with. And because your SQL command depends on the current content of the Combobox it's essential to fixing the problem to know exactly what is being used.

So, it's going to be up to you.
Fortunately, you have a tool available to you which will help you find out what is going on: the debugger. If you don't know how to use it then a quick Google for "Visual Studio debugger" should give you the info you need.

Put a breakpoint on the first line in the function, and run your code through the debugger. Then look at your code, and at your data and work out what should happen manually. Then single step each line checking that what you expected to happen is exactly what did. When it isn't, that's when you have a problem, and you can back-track (or run it again and look more closely) to find out why.

Sorry, but we can't do that for you - time for you to learn a new (and very, very useful) skill: debugging!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900