Ver Mensaje Individual
  #19  
Antiguo 06-01-2008
LENOCB LENOCB is offline
Miembro
 
Registrado: dic 2008
Ubicación: Argentina
Posts: 54
Reputación: 17
LENOCB Va por buen camino
Código Delphi [-]procedure TFormGrupos.Edit1Exit(Sender: TObject);
begin //Si el Campo del Nombre no está completo salta un error.
If (Edit1.Text='')then begin MessageDlg('Este Campo debe completarse ',mtError,[mbOk],0);
Edit1.SetFocus;
end;
end;

procedure TFormGrupos.BitBtn1Click(Sender: TObject); //Agrega un Grupo sino está en la Tabla TGrupos.
Var agregar:String;
CO:Integer;
begin //Primero Buscar el Registro para ver si está . Y verifica tambien el codigo
FormGrupos.ADOQuery1.Active := False;
FormGrupos.ADOQuery1.SQL.Text := 'Select Nombre From TGrupos WHERE Nombre = :Nombre';
FormGrupos.ADOQuery1.Parameters.Parambyname('Nombre').Value:= Edit1.Text;
FormGrupos.ADOQuery1.Active := True;
If Edit1.Text = FormGrupos.ADOQuery1.Fields[0].Value then begin MessageDlg('El Grupo : '+Edit1.Text+' ya Existe ',mtError,[mbOK],0);
Edit1.text:='';
Edit1.SetFocus;
end else begin //Ahora me fijo el Código si ya existe.
//FormGrupos.ADOQuery1.SQL.Clear;
//FormGrupos.ADOQuery1.Active := False;
FormGrupos.ADOQuery1.SQL.Text:= 'Select Cod_G From TGrupos Where Cod_G = :Cod';
FormGrupos.ADOQuery1.Parameters.Parambyname('Cod').Value:=StrToInt(FormGrupos.Edit2.Text);
FormGrupos.ADOQuery1.Active:=true;
If StrToInt(Edit2.text) = FormGrupos.ADOQuery1.Fields[0].Value Then begin MessageDlg('El Código: '+Edit2.Text+', ya existe', mtError,[mbOk],0);
Edit2.Text:='';
Edit2.SetFocus;
end else //Esta todo bien entonces agrego.
begin FormGrupos.ADOQuery1.Active := False; FormGrupos.ADOQuery1.SQL.Text:= 'Insert Into TGrupos (Nombre, Cod_G) Values (:Nombre, :Codigo)';
FormGrupos.ADOQuery1.Parameters.Parambyname('Nombre').Value:= Edit1.Text;
FormGrupos.ADOQuery1.Parameters.Parambyname('Codigo').Value:= StrToInt(Edit2.Text);
FormGrupos.ADOQuery1.ExecSQL;
end;
end;


he probado mandandole el numero directo es decir :
FormGrupos.ADOQuery1.Parameters.Parambyname('Cod').Value:= 4
por ejemplo y salta el mismo error
Responder Con Cita