Q&A

  • 파라메타에 Integer 를 던지면 OleStr ->Double 변환오류발생??
OS : Windows 2003 Server
DB : MS-SQL 2000

델파이코드상으로  SELECT 및 UPDATE / INSERT 모든 문장상에 파라메타를 던지면 오류가 발생합니다.
ADO Component 가 사용되었고요.
에러메시지가 'Could not conver variant of type(OleStr) into type(Double)' 가 나옵니다.  
이런 경우는 첨이라.. 좀 당황스럽니다.  

프로그램 처리는 다음과 같이 되었습니다.


s := 'INSERT INTO Adm_Mod_Sys ( MOD_ID, Mod_Seq, Hand_Type , Grp_Field )'+
        'VALUES ( :ModuleNo , :ModSeq , :HandType , :GrpField ) ;

     with Ds.CBDataSet4, cxView1.DataController do
     begin
          Ds.CBMidasCon1.BeginTran;
          try
             close;
             params.clear;
             Sql.Text := s ;
             params.CreateParam(ftString, 'ModuleNo' , ptInput ) ;
             Params.CreateParam( ftInteger , 'ModSeq', ptInput );
             Params.CreateParam( ftInteger , 'HandType', ptInput );
             Params.CreateParam( ftInteger, 'GrpField', ptInput );

             Params.ParamValues['ModuleNo']     := cModuleNo ;
             nMaxSeq := MaxSeq + 1 ;
              Params.ParamValues['ModSeq'] :=  nMaxSeq ; <<<<--

             if Radio_1.checked then
                Params.ParamValues['HandType']    := 0      <<<<--
             else if Radio_2.Checked then
                Params.ParamValues['HandType']    := 1 ;    <<<<--

             if Radio_1.checked then
                Params.ParamValues['GrpField'] :=  RzSpinEdit1.Value  <<<<--
             else if Radio_2.Checked then
                Params.ParamValues['Grp_Field'] := RzSpinEdit2.Value   ; <<<<--

             Execute ;
             Ds.CBMidasCon1.CommitTran ;
         except
             Ds.CBMidasCon1.RollBackTran ;
         end;



여기서 숫자로 파라메타로 전달되어지는 값들이 Integer 로 되어 있는 부분에서 오류발생
컴파일오류는 아닙니다.    <<<<-- 로 표시된 부분을 모두 문자열 형태로 변경하면 정상적으로 작동합니다.

예를 들어
...
             if Radio_1.checked then
                Params.ParamValues['HandType']    := '0'      <<<<--
             else if Radio_2.Checked then
                Params.ParamValues['HandType']    := '1' ;    <<<<--
...

이렇게 처리하면 오류발생하지 않음.

도대체 왜 이런 현상이 발생할까요?


1  COMMENTS
  • Profile
    nilriri™ 2005.05.01 09:43

              try
                 close;
                 Sql.Text := s ;
                 params.clear;   <-- 순서를 바꿔 보시구요..^^;  

    제가 봐서 ADO가 아니고 BDE 같습니다.

    파라미터 지정은 아래처럼 해보시구요..^^;

           Query1.Params.ParamByName('ParamName').AsInteger



    ADO에는 저런 메소드가 없거든요..ㅡㅡ;

    with ADOComponet...  do
    begin
            
          .....

                   ProcedureName := 'sp_getInsaOfSosuk';
                   Parameters.Clear;
                   Parameters.CreateParameter(':AKey',ftInteger,pdInput,10, li_Key);

         ....

    end;

    ADO같은 경우 이렇게 하면 에러 없이 잘 처리 되더군요..