Conectando na DBGrid

Delphi

05/09/2003

pessoal eu to me conectando a uma grid assim:
 
with DtaObjetos do
        begin
           oCn.Connected := True;
           oCn.Open;
           with qryQuery do
           begin
            Active := True;
            Close;
            SQL.Clear;
            SQL.Add(´Select * from tblaluno where matricula = -1´);
            Open;
            ExecSQL;
           end;
           DtsGrid.DataSet := qryQuery;
           dbgAluno.DataSource := DtsGrid;
           //oCn.Close;
           //oCn.Connected := False;
           //qryQuery.Close;
           //qryQuery.Active := False;
        end;


Qd eu vou pesquisar eu faço assim mas dá erro.... o erro me informa q não aceita Multiplos registros.... o código tá assim:
if edtPesq.Text <> ´´ then
       begin
        with DtaObjetos do
        begin
           oCn.Close;
           oCn.Connected := False;
           oCn.Connected := True;
           oCn.Open;
           with qryQuery do
           begin
            Active := False;
            Active := True;
            Close;
            SQL.Clear;
            SQL.Add(´Select * from tblaluno where nome = "´+ edtPesq.Text +´"´);
            Open;
            ExecSQL;
           end;
           //DtsGrid.Free;
           //dbgAluno.Free;
           //DtsGrid.DataSet := qryQuery;
           //dbgAluno.DataSource := DtsGrid;
           //oCn.Close;
           //oCn.Connected := False;
           //qryQuery.Close;
           //qryQuery.Active := False;
        end;
        end
        else
           ShowMessage(´Por favor, digite algo´);
           edtPesq.SetFocus;
        end;

Como eu não posso me desconectar por causa da grid na primeira etapa eu fecho a conexão e o meu query nessa segunda etapa e tento realimentar a grid.... mas da erro no ´ExecSQL´.... Alguém sabe o q pode ser...?!


Brenerfa

Brenerfa

Curtidas 0

Respostas

Biscoitorfa

Biscoitorfa

05/09/2003

vc naum pode dar um ExecSQL em consultas!!! Apenas Open! Irá da erro mesmo!


GOSTEI 0
Brenerfa

Brenerfa

05/09/2003

Como asim..?!


GOSTEI 0
Brenerfa

Brenerfa

05/09/2003

Pessoal tá dando erro no ´Open´
ele diz q o dataset não suporta bookmark com multiplo rgistros nos controls


GOSTEI 0
POSTAR