无法在VB.NET中使用MySQL显示记录

时间:2016-01-28 16:14:22

标签: mysql vb.net

Imports MySql.Data.MySqlClient


Public Class home1
    Dim id As String
    Dim name1 As String
    Dim name2 As String
    Dim address As String
    Dim age As Integer
    Dim gender As String
    Dim bday As Date
    Dim height1 As String
    Dim weight1 As String
    Dim crimcase As String
    Dim eye As String
    Dim con As New MySqlConnection
    Dim source1 As New BindingSource()
    Dim source2 As New BindingSource()
    Dim ds As DataSet = New DataSet
    Dim tables As DataTableCollection = ds.Tables




    Private Sub home1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try

            con.ConnectionString = "Server=localhost;User Id=root;Password='';Database=db_criminalrecord"
        Catch ex As Exception
            MsgBox(ex.Message)




        End Try
        fill()

    End Sub

    Public Sub fill()
        Dim dt As New DataTable
        Dim str As String = "SELECT ID,Criminal_Name,Alias,Address,Age,Gender,Height,Weight,Date_of_Birth,criminal_Case,Eye_Colour "
        Dim da As New MySqlDataAdapter(str, con)
        da.Fill(dt)
        da.Dispose()
        source1.DataSource = dt
        DataGridView1.DataSource = dt
        DataGridView1.Refresh()
        DataGridView1.Columns(13).Width = 150

    End Sub

    Sub clear()

        TextBox1.Text = ""
        TextBox2.Text = ""
        TextBox3.Text = ""
        TextBox4.Text = ""
        TextBox5.Text = ""
        TextBox6.Text = ""
        TextBox7.Text = ""
        TextBox8.Text = ""
        TextBox9.Text = ""
        TextBox10.Text = ""
    End Sub



End Class

1 个答案:

答案 0 :(得分:0)

您的select语句不包含FROM TABLE_NAME部分。