Consulta em banco mysql - nao estou conseguindo

Delphi

06/10/2005

Salve,

iniciei um novo projeto asp.net com o delphi 2005, estou tentando acessar uma base de dados em mysql estou fazendo assim:

var Dreader : OdbcDataReader; Comando : OdbcCommand; Str : string; begin Str := ´select razao from cliente where idcliente = @idcliente´; Comando := OdbcCommand.Create( Str, ConnLogonCliente ); Comando.Parameters.Add( ´@idcliente´, OdbcType.NVarChar, 20, ´idcliente´); Comando.Parameters[ ´@idcliente´ ].Value := logon; try Comando.Connection.Open(); Dreader := Comando.ExecuteReader(); Label3.Text := Dreader.Item[ ´razao´ ].ToString; finally Dreader.Close(); Comando.Connection.Close(); end; end;


minha string de conexăo: DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=mafil;UID=root;PASSWORD=uroot;OPTION=3;

O erro que esta sendo retornado no browser: Server Error in ´/mafil´ Application.
--------------------------------------------------------------------------------

No data exists for the row/column.

esta linha vem descada de vermelho: Line 191: Label3.Text := Dreader.Item[ ´razao´ ].ToString;

alguem ai pode me dar um help?


Mmoreira

Mmoreira

Curtidas 0

Respostas

Otto

Otto

06/10/2005

var Dreader : OdbcDataReader; Comando : OdbcCommand; Str : string; begin Str := ´select razao from cliente where idcliente = @idcliente´; Comando := OdbcCommand.Create( Str, ConnLogonCliente ); Comando.Parameters.Add( ´@idcliente´, OdbcType.NVarChar, 20, ´idcliente´); Comando.Parameters[ ´@idcliente´ ].Value := logon; try Comando.Connection.Open(); Dreader := Comando.ExecuteReader(); [b:3f630e794a]Dreader.read();[/b:3f630e794a] Label3.Text := Dreader.Item[ ´razao´ ].ToString; finally Dreader.Close(); Comando.Connection.Close(); end; end;


tenta agora :)


GOSTEI 0
Mmoreira

Mmoreira

06/10/2005

valew Otto

Isso resolveu meu problema!!!


GOSTEI 0
POSTAR