Imports MySql.Data.MySqlClient
Public Class Form7
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim serverstring As String = "Data Source=localhost;Database=project;User ID=root;password=1234"
Dim conn As New MySqlConnection(serverstring)
conn.Open()
Dim sql As String = "SELECT * FROM personnel "
Dim cmd As New MySqlCommand(sql, conn)
Dim adapter As New MySqlDataAdapter(cmd)
Dim data As New DataSet()
adapter.Fill(data, "per")
Dim name As String = ""
For i = 0 To data.Tables("per").Rows.Count - 1
name = data.Tables("per").Rows(i)("personnel_name")
ListBox1.Items.Add(name)
Next
conn.Clone()
End Sub
End Class
มัน error : Unable to convert MySQL date/time value to System.DateTime ผมไม่รู้ว่าจะแก้งัยครับ ช่วยผมหน่อยนะครํบ
Public Class Form7
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim serverstring As String = "Data Source=localhost;Database=project;User ID=root;password=1234"
Dim conn As New MySqlConnection(serverstring)
conn.Open()
Dim sql As String = "SELECT * FROM personnel "
Dim cmd As New MySqlCommand(sql, conn)
Dim adapter As New MySqlDataAdapter(cmd)
Dim data As New DataSet()
adapter.Fill(data, "per")
Dim name As String = ""
For i = 0 To data.Tables("per").Rows.Count - 1
name = data.Tables("per").Rows(i)("personnel_name")
ListBox1.Items.Add(name)
Next
conn.Clone()
End Sub
End Class