阅读背景:

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

来源:互联网 
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
Imports MySql.Data.MySqlClient


Public Class h



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: