2 messages in com.mysql.lists.dotnetRE: Problem with using DataGrid with ...
FromSent OnAttachments
Junkkarinen Matti11 Jul 2005 00:38 
Blue Wave Software11 Jul 2005 17:55 
Subject:RE: Problem with using DataGrid with MySQL
From:Blue Wave Software (mys@bluewavesoftware.com.au)
Date:07/11/2005 05:55:34 PM
List:com.mysql.lists.dotnet

Try using a data adapter instead.

----------------------------------------------------------------------------

Dim MyConnection as New MySqlConnection Dim MyCommand as New MySqlCommand Dim MyDataAdapter as New MySqlDataAdapter Dim MyDataSet an New DataSet

MyConnection.ConnectionString = "....." MyConnection.Open

MyCommand.CommandText = "Select Field1, Field2, Field3 From Table" MyCommand.Connection = MyConnection

MyDataAdapter.SelectCommand = MyCommand

'If you want to update the table you could generate the Update, Insert and Delete commands for the DataAdapter

MyDataAdapter.fill(MyDataSet)

Me.grid1.DataSource = MyDataSet.Tables(0) Me.grid1.DataBind

----------------------------------------------------------------------------

Regards, Justin Elward

-----Original Message----- From: Junkkarinen Matti [mailto:Matt@ponsse.com] Sent: Monday, 11 July 2005 5:39 PM To: 'dot@lists.mysql.com' Subject: Problem with using DataGrid with MySQL

Hi!

I'm having a problem with displaying values retrieved from MySQL-database in DataGrid. If I use the simple code like following, only 6 first columns of the table in question are shown in the datagrid:

MyConnection.Open()

MyCommand.CommandText = "SELECT * FROM f_case"

MyCommand.Connection = MyConnection

MyReader = MyCommand.ExecuteReader

DataGrid1.DataSource = MyReader

DataGrid1.DataBind()

Do While MyReader.Read

Loop

MyReader.Close()

MyConnection.Close()

I get only 6 columns no matter which table I choose. There are no null values in any fields. If I'm using Oracle in stead of MySQL everything works perfectly so the problem is not in the code, but in the MySQL-database or its connection.

Could anyone help me with this?

Thanks in advance.

Regards,

Matti