Montar selct
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
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$
Curtidas 0
Respostas
Sremulador
04/07/2005
você pode utilizar um locate tb funciona
GOSTEI 0
$grandaum$
04/07/2005
obrigado pela dica mas eu naum sei ultilizar o Locate, poderia me dar um exemplo.....obrigado
GOSTEI 0
Rjun
04/07/2005
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;
GOSTEI 0
Ivanh
04/07/2005
/*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;
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;
GOSTEI 0
$grandaum$
04/07/2005
eu to usando o SqlConnection e pra fazer e o SqlDataSet pra cada tabela,
GOSTEI 0
$grandaum$
04/07/2005
[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
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
GOSTEI 0
Ivanh
04/07/2005
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!
GOSTEI 0
$grandaum$
04/07/2005
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
GOSTEI 0
$grandaum$
04/07/2005
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;
ocorre o seguinte erro
[Error] UnitPrincipal.pas(157): Incompatible types: ´TSQLConnection´ and ´String´
GOSTEI 0
$grandaum$
04/07/2005
[quote:8cd19e3993=´$Grandaum$´]
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(´ ´);
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;
ocorre o seguinte erro
[Error] UnitPrincipal.pas(157): Incompatible types: ´TSQLConnection´ and ´String´[/quote:8cd19e3993]
e tb oq viria dentro do Sql.add(´ ´);
GOSTEI 0
Sremulador
04/07/2005
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, [...])
GOSTEI 0