Dim dsUser As New DataSet
Dim _condb As New ConnectionDBClass ' ประกาศ ตัวแปร เพื่อเรียกใช้งาน คลาส ConnectionDBClass
Dim sb As New StringBuilder
Me._condb.connectDB()
sb.Remove(0, sb.Length)
sb.Append(" SELECT * FROM tbCustomers ")
Me._condb.da = New MySqlDataAdapter(sb.ToString(), Me._condb.con)
Me._condb.da.Fill(dsUser, "tbCustomers ")
TbCustomersDataGridView.DataSource = dsUser.Tables("tbCustomers")
Imports MySql.Data
Imports MySql.Data.MySqlClient
Public Class ConnectionDBClass
Public con As New MySqlConnection
'Public com As New MySqlCommand
'Public da As New MySqlDataAdapter
'Public tr As MySqlTransaction
'Private Dr As MySqlDataReader
'Private ds As DataSet
'Private dt As DataTable
Public Function connectDB() As Boolean
If con.State = ConnectionState.Open Then con.Close()
con.ConnectionString = "Server=localhost;User Id=root; Password=654321; Database=Maintenance; Pooling=false"
con.Open()
Return (True)
End Function
End Class
Imports MySql.Data
Imports MySql.Data.MySqlClient
Public Class ConnectionDBClass
Public con As New MySqlConnection
'Public com As New MySqlCommand
'Public da As New MySqlDataAdapter
'Public tr As MySqlTransaction
'Private Dr As MySqlDataReader
'Private ds As DataSet
'Private dt As DataTable
Public Function connectDB() As Boolean
If con.State = ConnectionState.Open Then con.Close()
con.ConnectionString = "Server=localhost;User Id=root; Password=654321; Database=Maintenance; Pooling=false"
con.Open()
Return (True)
End Function
End Class
ข้างบน ตัวสีแดง มันถูก mark เอาไว้ ถือว่าไม่มีตัวตนครับ
Code
Dim dsUser As New DataSet
Dim _condb As New ConnectionDBClass ' ประกาศ ตัวแปร เพื่อเรียกใช้งาน คลาส ConnectionDBClass
Dim sb As New StringBuilder
Me._condb.connectDB()
sb.Remove(0, sb.Length)
sb.Append(" SELECT * FROM tbCustomers ")
Me._condb.da = New MySqlDataAdapter(sb.ToString(), Me._condb.con)
Me._condb.da.Fill(dsUser, "tbCustomers ")
TbCustomersDataGridView.DataSource = dsUser.Tables("tbCustomers")
Try
Me._condb.da = New MySqlDataAdapter(sb.ToString(), Me._condb.con)
Me._condb.da.Fill(dsUser, "tbCustomers ")
Catch ex As Exception
msgbox( ex.Message)
End Try
This is not a bug but expected behavior. Please check manual under connect options and set "Allow Zero Datetime" to true, as on attached pictures, and the error will go away.
Set both of these configurations in your connection string.
"Convert Zero Datetime=True"
"Allow Zero Datetime=True"
งั้นก็ลองแก้เป็น
con.ConnectionString = "Server=localhost;User Id=root; Password=654321; Database=Maintenance; Pooling=false ; Convert Zero Datetime=True; Allow Zero Datetime=True"