voldemmor
01-04-2008, 20:08:49
Hola amigos. Hos pido ayuda nuevamente, y de antemano les agradesco XD.
El Problema:
Estoy usando Compponentes Zeos+ delphi 6 + Mysql5
Tengo que hacer la insercion de varias notas a una tabla, pero al momento de de ejecutar el SQL de insercion me da un error
Out of range value adjusted for colum 'nota' at row 1
Valor fuera de rango en la cumna 'nota' en la fila1
el codigo
procedure TfrmNotas.BitBtn1Click(Sender: TObject);
var cant,i : integer;
begin
cant := sgNotas.RowCount - 1;
try
AcademicData.ZConnection1.StartTransaction;
with AcademicData.ZQuery1 do
begin
{.....inicia el trabajo dentro de la transaccion........}
sql.Clear;
SQL.Text := 'INSERT INTO nota (cod_estudiante,cod_matricula,cod_periodo,cod_materia,nota,detalle)'+
'VALUES(:pcod_estudiante,:pcod_matricula,:pcod_periodo,:pcod_materia,:pnota,:pdetalle)';
for i := 1 to cant do
begin
{insercion masiva de datos------falta}
ParamByName('pcod_estudiante').AsInteger:= strtoint(sgNotas.Cells[1,i]);
ParamByName('pcod_matricula').AsInteger:= strtoint(sgNotas.Cells[0,i]);
{periodo de notas}
ParamByName('pcod_periodo').AsInteger:= CodigoPeriodoEvaluacion(cbxPeriodoNotas.Text);
ParamByName('pcod_materia').AsInteger:= CodigoMateriaNombre(cbxMateria.Text);
ParamByName('pnota').AsFloat:=StrToFloat(sgNotas.Cells[3,i]);
ParamByName('pdetalle').AsString:=sgNotas.Cells[4,i];
ExecSQL;
end;
Close
end;
AcademicData.ZConnection1.Commit;
except
AcademicData.ZConnection1.Rollback;
AcademicData.ZQuery1.Close;
end;
end;
y la tabla esta asi
CREATE TABLE `nota` (
`codigo` int(11) NOT NULL auto_increment,
`cod_estudiante` int(11) default NULL,
`cod_matricula` int(11) default NULL,
`cod_periodo` int(11) default NULL,
`cod_materia` int(11) default NULL,
`nota` float(2,2) NOT NULL default '0.00',
`detalle` varchar(30) default NULL,
PRIMARY KEY (`codigo`),
KEY `cod_estudiante` (`cod_estudiante`),
KEY `cod_matricula` (`cod_matricula`),
KEY `cod_periodo` (`cod_periodo`),
CONSTRAINT `nota_coducta_fk` FOREIGN KEY (`cod_estudiante`) REFERENCES `estudiantes` (`codigo`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `nota_coducta_fk1` FOREIGN KEY (`cod_matricula`) REFERENCES `matriculas` (`codigo`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `nota_coducta_fk2` FOREIGN KEY (`cod_periodo`) REFERENCES `periodos` (`codigo`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
El Problema:
Estoy usando Compponentes Zeos+ delphi 6 + Mysql5
Tengo que hacer la insercion de varias notas a una tabla, pero al momento de de ejecutar el SQL de insercion me da un error
Out of range value adjusted for colum 'nota' at row 1
Valor fuera de rango en la cumna 'nota' en la fila1
el codigo
procedure TfrmNotas.BitBtn1Click(Sender: TObject);
var cant,i : integer;
begin
cant := sgNotas.RowCount - 1;
try
AcademicData.ZConnection1.StartTransaction;
with AcademicData.ZQuery1 do
begin
{.....inicia el trabajo dentro de la transaccion........}
sql.Clear;
SQL.Text := 'INSERT INTO nota (cod_estudiante,cod_matricula,cod_periodo,cod_materia,nota,detalle)'+
'VALUES(:pcod_estudiante,:pcod_matricula,:pcod_periodo,:pcod_materia,:pnota,:pdetalle)';
for i := 1 to cant do
begin
{insercion masiva de datos------falta}
ParamByName('pcod_estudiante').AsInteger:= strtoint(sgNotas.Cells[1,i]);
ParamByName('pcod_matricula').AsInteger:= strtoint(sgNotas.Cells[0,i]);
{periodo de notas}
ParamByName('pcod_periodo').AsInteger:= CodigoPeriodoEvaluacion(cbxPeriodoNotas.Text);
ParamByName('pcod_materia').AsInteger:= CodigoMateriaNombre(cbxMateria.Text);
ParamByName('pnota').AsFloat:=StrToFloat(sgNotas.Cells[3,i]);
ParamByName('pdetalle').AsString:=sgNotas.Cells[4,i];
ExecSQL;
end;
Close
end;
AcademicData.ZConnection1.Commit;
except
AcademicData.ZConnection1.Rollback;
AcademicData.ZQuery1.Close;
end;
end;
y la tabla esta asi
CREATE TABLE `nota` (
`codigo` int(11) NOT NULL auto_increment,
`cod_estudiante` int(11) default NULL,
`cod_matricula` int(11) default NULL,
`cod_periodo` int(11) default NULL,
`cod_materia` int(11) default NULL,
`nota` float(2,2) NOT NULL default '0.00',
`detalle` varchar(30) default NULL,
PRIMARY KEY (`codigo`),
KEY `cod_estudiante` (`cod_estudiante`),
KEY `cod_matricula` (`cod_matricula`),
KEY `cod_periodo` (`cod_periodo`),
CONSTRAINT `nota_coducta_fk` FOREIGN KEY (`cod_estudiante`) REFERENCES `estudiantes` (`codigo`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `nota_coducta_fk1` FOREIGN KEY (`cod_matricula`) REFERENCES `matriculas` (`codigo`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `nota_coducta_fk2` FOREIGN KEY (`cod_periodo`) REFERENCES `periodos` (`codigo`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;