Salve ho creato un codcie di prova
Imports System.Data
Imports MySql.Data.MySqlClient
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim conn As New MySqlConnection("server=localhost;username=root;password=12345;database=test")
conn.Open()
Dim da As New MySqlDataAdapter("Select * from test", conn)
Dim dt As New DataTable
da.Fill(dt)
DataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect
DataGridView1.DataSource = dt
conn.Close()
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim conn As New MySqlConnection("server=localhost;username=root;password=12345;database=test")
conn.Open()
Dim cmd As MySqlCommand
Dim reader As MySqlDataReader
cmd = New MySqlCommand("SELECT * FROM test", conn)
reader = cmd.ExecuteReader
While reader.Read
DataGridView2.Rows.Add(reader.GetString(0))
End While
conn.Close()
DataGridView2.Refresh()
End Sub
End Class
nel primo caso nel campo data/ora i socondi vengono troncati es. 26/08/2022 15:12
nel secondo caso invece vengono riportati es. 26/08/2022 15:12:08
Vorrei sapere perchè con datatable non compaiono e/o come fare.
Grazie