MySQLDataReader problem

MySQLDataReader problem

Postby Jeroen Vandezande » Mon 04 Apr 2005 15:37

Hi all,

I am trying to get access to a MySQL server using Delphi 2005 in a pure .net
winforms app.
I use corelabs MySQL connector for .net to do this.
The problem is that the datareader does not shows the data from columns 6,7
and 8.
It gives no errors , the fields appear empty...

here is the code:

****************************************************************************************
program SQLTest;
{$APPTYPE CONSOLE}
uses
corelab.mysql;
var
param: MySqlParameter;
cmd: MySqlCommand;
SQLStatement: string;
reader: MySqlDataReader;
SQLConnection: MySqlConnection;
begin
SQLConnection := nil;
reader := nil;
try
SQLConnection := MySqlConnection.Create('User Id=root;Password=delphi;Host=localhost;Database=pressurelogger');
SQLConnection.Open;

SQLStatement := 'SELECT (runtime * 20) AS numberofsamples, (fadeouttime * 20) AS numberoffadeoutsamples, ' +
'tone1, tone2, tone1duration, tone2duration, pumpoffset, cartridgename, shortname ' +
'FROM cartridges, operators, pumps ' +
'WHERE pumps.userid=operators.index ' +
'AND pumps.cartridgeid=cartridges.index ' +
'AND pumps.pumpipaddress=@IpAddress';


cmd := MySqlCommand.Create(SQLStatement, SQLConnection);
param := MySqlParameter.Create;
param.ParameterName := '@IpAddress';
param.Value := '192.168.10.15';
cmd.Parameters.Add(param);
reader := cmd.ExecuteReader;
while reader.Read do
begin
Console.WriteLine(reader['shortname']);
end;
finally
if (reader <> nil) then
reader.Close;
if (SQLConnection <> nil) then
SQLConnection.Close;
end;
end.
****************************************************************************************************************

as you can see I ask the datareader to print out the value of the collumn
'shortname'. (a string field).
This gives an empty field.

If I change the SQL statement to this :

SQLStatement := 'SELECT (runtime * 20) AS numberofsamples, (fadeouttime * 20) AS numberoffadeoutsamples, shortname, ' +
'tone1, tone2, tone1duration, tone2duration, pumpoffset, cartridgename ' +
'FROM cartridges, operators, pumps ' +
'WHERE pumps.userid=operators.index ' +
'AND pumps.cartridgeid=cartridges.index ' +
'AND pumps.pumpipaddress=@IpAddress';

Then it works correctly!
The only thing I did was to put the shortname field on other place in the
select statement... still the last 3 fields are empty but the shortname
field is now field #3 and gets filled.
Can someone give me a solution to get all the fields working?

Best Regards,

Jeroen Vandezande.
Jeroen Vandezande
 
Posts: 2
Joined: Mon 04 Apr 2005 15:32

Postby Serious » Mon 04 Apr 2005 16:00

Trial version of the provider is limited by number of the returned table columns. MySQLDirect .NET trial version returns result set with maximum 6 columns. Extra select-list columns are truncated.
Serious
 

Postby Jeroen Vandezande » Mon 04 Apr 2005 23:09

oleg542 wrote:Trial version of the provider is limited by number of the returned table columns. MySQLDirect .NET trial version returns result set with maximum 6 columns. Extra select-list columns are truncated.


Thank you for the swift reply!
The strange thing is that I have downloaded a trial version a time ago, and after testing it and finding it good we ordered the full version.
I installed that version but somehow the trial DLL is still used... strange.
anyway now I know in what direction I have to look.

Thank you!
Jeroen Vandezande
 
Posts: 2
Joined: Mon 04 Apr 2005 15:32

Postby Serious » Tue 05 Apr 2005 07:07

Try to reinstall MySQLDirect .NET. Check before that MySQLDirect isn't installed and there are no CoreLab.MySql.dll, CoreLab.MySql.Addin.dll, CoreLab.MySql.Design.dll files in GAC.
Serious
 


Return to dotConnect for MySQL