Jump to content


Datagrid problems

  • Please log in to reply
No replies to this topic

#1 Nightscream


    Young Padawan

  • Members
  • Pip
  • 100 posts
  • Gender:Male
  • Location:Belgium

Posted 02 June 2008 - 01:27 PM


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
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)


			data = New DataTable
			Adapter = New MySqlDataAdapter("SELECT `ordernr`, `orderdatum`, `klantnaam`, `omschrijving` FROM `order`".ToString, conn)
			CommandBuild = New MySqlCommandBuilder(Adapter)

			dgrOrders.DataSource = data
		Catch ex As MySqlException
			MessageBox.Show("Er is een probleem opgetreden: " + ex.Message)
		End Try

	End Sub
End Class

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users