Q&A

  • Delphi3.0 Type MisMatch Error
Delphi3.0을 사용하고 있습니다.DB는 Paradox이구요.
Excel File을 불러서 DB에 Insert하는 과정인데요.
DB삭제는 정상적으로 잘 되는데....
Insert를 하면 Type MisMatch Error가 뜨네요..
Type은 잘 맞춰진것 같은데..이해가 안됩니다.


procedure TF_ErrorCode.Button1Click(Sender: TObject);
var
   ExcelFileName : String;
begin
   OpenDialog1.InitialDir := ExtractFilePath(Application.ExeName);
   if OpenDialog1.Execute then
   begin
      ExcelFileName := OpenDialog1.FileName;
      with ADOQuery1 do
      begin
         Close;
         ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;DataSource='+
                              ExcelFileName+ ';  
                              ExtendedProperties=Excel8.0;
                              Persist Security Info=False';
         Sql.Clear;
         SQL.Text := 'Select * from [ErrorCode$] where Code > 0 '   ;
         open;
      end;
   end;
end;

procedure TF_ErrorCode.Button2Click(Sender: TObject);
var
   Q_text : String;
begin
   Case RadioGroup1.ItemIndex of
     0,1:begin
            if (not ADOQuery1.Active) or (ADOQuery1.IsEmpty) then
            begin
               ShowMessage('자료가 없습니다');
               Exit;
            end;
            Q_text := ' INSERT INTO Errcode ' +
                         '       (  Code,  Grade,    DesCription ) ' +
                           //   ,   Action ,  PositionQ,  PositionX, PositionY
                         ' VALUES(  :Code, :Grade,  :DesCription) ' ;  
                         //   , :Action,  :PositionQ, :PositionX, :PositionY

            try
               while not ADOQuery1.Eof  do
               begin
                  IF (ADOQuery1.FieldByName('Code').IsNull) or  
                       (ADOQuery1.FieldByName('Code').AsInteger = 0) then
                  else
                  begin
                     with Qry_Insert do
                     begin
                        Close;
                        Sql.Clear;
                        Sql.Text := Q_text;
ParamByName('Code').Value         :=
                    StrToInt(Trim(ADOQuery1.FieldByName('Code').AsString));
ParamByName('Grade').Value        :=
                    StrToInt(Trim(ADOQuery1.FieldByNam('Grade').AsString));
ParamByName('DesCription').Value  :=
                     Trim(ADOQuery1.FieldByName('DesCription').AsString);
                       // ParamByName('Action').AsMemo      := Trim(ADOQuery1.FieldByName('Action').AsString);
                        //ParamByName('PositionQ').Value    := StrToint(Trim(ADOQuery1.FieldByName('PositionQ').AsString));
                       // ParamByName('PositionX').Value    := StrToint(Trim(ADOQuery1.FieldByName('PositionX').AsString));
                       // ParamByName('PositionY').Value    := StrToint(Trim(ADOQuery1.FieldByName('PositionY').AsString));

                        ExecSQL;

                     end;
                  end;
                  ADOQuery1.Next;
               end;
               ShowMessage('ÀÚ·á°¡ ÀúÀåµÇ¾ú½À´Ï´Ù.');
               RadioGroup1.ItemIndex := 0;
            except
               ShowMessage('ÀÚ·áÀúÀåÁß ¿¡·¯°¡ ¹ß»ýÇß½À´Ï´Ù.');
            end;
         end;
       2:begin
            Q_text := ' DELETE FROM ErrCode ';
            if MessageDlg('삭제',mtConfirmation,[mbYes,mbno],0) = mryes then
            begin
               with Qry_Insert do
               begin
                  Close;
                  Sql.Clear;
                  Sql.Text := Q_text;
                  ExecSQL;
               end;
               ADOQuery1.Close;
               RadioGroup1.ItemIndex := 0;
            end;
         end;
   end;
end;
0  COMMENTS