Fórum Montar selct #286860

04/07/2005

0

eu to tentando fazer o sistema q tenha uma catraca, eu preciso saber c existe o cogido na tabela de clientes, caso o codigo exista ele tem q voltar duas mensagem uma eh de Liberado outra eh o nome do cliente
eu to tentando algo desse tipo, mas sei q estah errado

aos pouco vou aprimorar esse select tipo conferir a data de vencimento, a situacao dele, c o aluno ainda continua na academia ou jah trancou a matricula

select
CODIGO, NOMECLI
from
CLIENTE
where

if (:edcodigo.text = codigo)
{lbsituacao:= ´liberado´ }
else
(lbsituacao:= ´codigo inexistente´)


obrigo pessoal


$grandaum$

$grandaum$

Responder

Posts

04/07/2005

Sremulador

você pode utilizar um locate tb funciona


Responder

Gostei + 0

04/07/2005

$grandaum$

obrigado pela dica mas eu naum sei ultilizar o Locate, poderia me dar um exemplo.....obrigado


Responder

Gostei + 0

04/07/2005

Rjun

Query1.SQL.Clear;
Query1.SQL.Add(´select CODIGO, NOMECLI from CLIENTE where CODIGO = :Codigo´);
Query1.Parameters.ParamByName(´Codigo´).Value = edtCodigo.Text;

Query1.Open;
try
  if Query1.IsEmpty then
    lblsituacao.Caption := ´Acesso liberado´
  else
    lblsituacao.Caption := ´Código não encontrado.´;
finally
  Query1.Close;
end;



Responder

Gostei + 0

04/07/2005

Ivanh

/*Usando dbExpress*/
with TSQLQuery.Create(nil) do
begin
try
SQLConnection := SuaConexao;
SQL.Clear;
SQL.Add(Format(´SELECT ETC... WHERE CODIGO = ¬s´,[Edit1.Text]));
Open;
if not Fields[0].IsNull then
begin
label1.caption := ´Achou´;
end
else
begin
label1.caption := ´Ñ Achou´;
end;
finally
Close;
Free;
end;
end;


Responder

Gostei + 0

04/07/2005

$grandaum$

eu to usando o SqlConnection e pra fazer e o SqlDataSet pra cada tabela,


Responder

Gostei + 0

04/07/2005

$grandaum$

[quote:ab828c9aa4=´$Grandaum$´]eu to usando o SqlConnection e pra fazer e o SqlDataSet pra cada tabela,[/quote:ab828c9aa4]]

Deixa eu reescrever tudu issu aki
eu uso o SqlConnection pra fazer conexao com o bd e uso o SqlDataSet pra fazer conexao com as tabelas.....pronto agora melhorou


Responder

Gostei + 0

04/07/2005

Ivanh

with TSQLQuery.Create(nil) do
begin
  try
  SQLConnection := ;
  SQL.Clear;
  SQL.Add(´´);
  SQL.Add(´´);
  Open;
  if not Fields[0].IsNull then
  begin

  end;
  finally
    Close;
    Free;
  end;
end;

Faz assim que funciona!


Responder

Gostei + 0

04/07/2005

$grandaum$

Query1.SQL.Clear;
Query1.SQL.Add(´select CODIGO, NOMECLI from CLIENTE where CODIGO = :Codigo´);
Query1.Parameters.ParamByName(´Codigo´).Value = edtCodigo.Text;

Query1.Open;
try
  if Query1.IsEmpty then
    lblsituacao.Caption := ´Acesso liberado´
  else
    lblsituacao.Caption := ´Código não encontrado.´;
finally
  Query1.Close;
end;


ele dah erro na 3º linha no Parameters


Responder

Gostei + 0

04/07/2005

$grandaum$

with TSQLQuery.Create(nil) do
begin
  try
  SQLConnection := ;
  SQL.Clear;
  SQL.Add(´´);
  SQL.Add(´´);
  Open;
  if not Fields[0].IsNull then
  begin

  end;
  finally
    Close;
    Free;
  end;
end;
Faz assim que funciona!


ocorre o seguinte erro
[Error] UnitPrincipal.pas(157): Incompatible types: ´TSQLConnection´ and ´String´


Responder

Gostei + 0

04/07/2005

$grandaum$

[quote:8cd19e3993=´$Grandaum$´]
with TSQLQuery.Create(nil) do
begin
  try
  SQLConnection := ;
  SQL.Clear;
  SQL.Add(´´);
  SQL.Add(´´);
  Open;
  if not Fields[0].IsNull then
  begin

  end;
  finally
    Close;
    Free;
  end;
end;
Faz assim que funciona!


ocorre o seguinte erro
[Error] UnitPrincipal.pas(157): Incompatible types: ´TSQLConnection´ and ´String´[/quote:8cd19e3993]

e tb oq viria dentro do Sql.add(´ ´);


Responder

Gostei + 0

05/07/2005

Sremulador

e tb oq viria dentro do Sql.add(´ ´);


o cod para a pesquisa da tabela

o locate fica assim

tabela.locate (´CAMPO DA TABELA´, campo a variavel a pesquisar, [...])


Responder

Gostei + 0

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar