Hi,
I didn't really know where to post, here or database so I posted it here(sorry if it's wrong!)
I'm trying to connect to a mysql database with vb.net(visual studio 2008), I can connect, load data in a datagrid and everything but when I fill my datagrid, my tables are set by itself possible to set the columns names manual and put data in the predefined columns? My second problem is how to change a column type, in my database I've got my datetime values in integer, I've got a code to convert it to date time but I get an error to change the value, the error is something similar to "Column type is int64 and not Date"
This is my code
Code:Imports MySql.Data.MySqlClient Public Class frmOrderoverzicht Dim conn As MySqlConnection Dim data As DataTable Dim Adapter As MySqlDataAdapter Dim CommandBuild As MySqlCommandBuilder Private Sub frmOrderoverzicht_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim connStr As String connStr = "server=localhost;user id=root; password=; database=mysql; pooling=false" conn = New MySqlConnection(connStr) Try conn.Open() conn.ChangeDatabase("orders") data = New DataTable Adapter = New MySqlDataAdapter("SELECT `ordernr`, `orderdatum`, `klantnaam`, `omschrijving` FROM `order`".ToString, conn) CommandBuild = New MySqlCommandBuilder(Adapter) Adapter.Fill(data) dgrOrders.DataSource = data Catch ex As MySqlException MessageBox.Show("Er is een probleem opgetreden: " + ex.Message) End Try End Sub End Class






Bookmarks