开发者

show mysql table names from vb.net

I'm having trouble listing all the tables in a certain database in vb.net:

Public Sub table_show()


        cmd.CommandText = "SHOW TABLES FROM '" + database + "'"

        MessageBox.Show(cmd.CommandText.ToString)


        Me.dataAdapter = New MySqlDataAdapter(cmd.CommandText, con)
        Dim commandBuilder As New MySqlCommandBuilder(Me.dataAdapter)
        Dim table As New DataTable()
        table.Lo开发者_如何学Gocale = System.Globalization.CultureInfo.InvariantCulture
        Me.dataAdapter.Fill(table)
        Form1.BindingSource1.DataSource = table
        Dim data As New DataSet()
        data.Locale = System.Globalization.CultureInfo.InvariantCulture
        Form1.DataGridView1.DataSource = Form1.BindingSource1
    End Sub

I used message box to see what's happening. And it seems like the query doesn't want those single quotes in there. Here's what the message box showed me:

SHOW TABLES FROM 'sqlgen'

It worked when I tried a direct query without the need for parameters:

SHOW TABLES FROM sqlgen

The error I was getting is an sql query error. How do I remove those single quotes in there so that I won't get the error.


Sometimes you might want the ` quotes not the ' quotes.

But, I dont follow. If the query doesnt like the single quotes, and you dont want them in there, remove them from the code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜