Q&A

  • 동적MDB 생성후 테이블생성 그후에??
소습니다.

ADOQuery1.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;' +
                                      'User ID=Admin;' +
                                      'Data Source=' + DBName + ';' +
                                      'Mode=Share Deny None;' +
                                      'Extended Properties="";' +
                                      'Jet OLEDB:System database="";' +
                                      'Jet OLEDB:Registry Path="";' +
                                      'Jet OLEDB:Database Password="";' +
                                      'Jet OLEDB:Engine Type=5;' +
                                      'Jet OLEDB:Database Locking Mode=1;' +
                                      'Jet OLEDB:Global Partial Bulk Ops=2;' +
                                      'Jet OLEDB:Global Bulk Transactions=1;' +
                                      'Jet OLEDB:New Database Password="";' +
                                      'Jet OLEDB:Create System Database=False;' +
                                      'Jet OLEDB:Encrypt Database=False;' +
                                      'Jet OLEDB:Don''t Copy Locale on Compact=False;' +
                                      'Jet OLEDB:Compact Without Replica Repair=False;'+
                                      'Jet OLEDB:SFP=False';


ADOQuery1.Active := False;

ADOQuery1.SQL.Clear;

ADOQuery1.SQL.Text:='Create table Rpt (YMD_date CHAR(10),Numb CHAR(3),X1 CHAR(10),'+
                  'X2 CHAR(10),X3 CHAR(10),X4 CHAR(10),X5 CHAR(10),SSum Char(10),Aavg Char(10),Rang Char(10))';

ADOQuery1.ExecSQL;

SetLength(secondStr, StrToInt(Combosample.Text));
SetLength(a, RptGridM.colCount-1);

for i:=1 to RptGridM.RowCount-1 do
begin
  FirstStr[0]:=RptGridM.Cells[0,i];
  FirstStr[1]:=RptGridM.Cells[1,i];

  a[0]:=FirstStr[0];
  a[1]:=FirstStr[1];

  if Combosample.Text = '02' then begin
        secondStr[0]:=RptGridM.Cells[2,i];
        secondStr[1]:=RptGridM.Cells[3,i];

        ThreeStr[0]:=RptGridM.Cells[4,i];
        ThreeStr[1]:=RptGridM.Cells[5,i];
        ThreeStr[2]:=RptGridM.Cells[6,i];

        a[2]:=secondStr[0];
        a[3]:=secondStr[1];
        a[4]:=' ';
        a[5]:=' ';
        a[6]:=' ';


  end else if Combosample.Text = '03' then begin
        secondStr[0]:=RptGridM.Cells[2,i];
        secondStr[1]:=RptGridM.Cells[3,i];
        secondStr[2]:=RptGridM.Cells[4,i];

        ThreeStr[0]:=RptGridM.Cells[5,i];
        ThreeStr[1]:=RptGridM.Cells[6,i];
        ThreeStr[2]:=RptGridM.Cells[7,i];

        a[2]:=secondStr[0];
        a[3]:=secondStr[1];
        a[4]:=secondStr[2];
        a[5]:=' ';
        a[6]:=' ';


  end else if Combosample.Text = '04' then begin
        secondStr[0]:=RptGridM.Cells[2,i];
        secondStr[1]:=RptGridM.Cells[3,i];
        secondStr[2]:=RptGridM.Cells[4,i];
        secondStr[3]:=RptGridM.Cells[5,i];

        ThreeStr[0]:=RptGridM.Cells[6,i];
        ThreeStr[1]:=RptGridM.Cells[7,i];
        ThreeStr[2]:=RptGridM.Cells[8,i];

        a[2]:=secondStr[0];
        a[3]:=secondStr[1];
        a[4]:=secondStr[2];
        a[5]:=secondStr[3];
        a[6]:=' ';

  end else if Combosample.Text = '05' then begin
        secondStr[0]:=RptGridM.Cells[2,i];
        secondStr[1]:=RptGridM.Cells[3,i];
        secondStr[2]:=RptGridM.Cells[4,i];
        secondStr[3]:=RptGridM.Cells[5,i];
        secondStr[4]:=RptGridM.Cells[6,i];

        ThreeStr[0]:=RptGridM.Cells[7,i];
        ThreeStr[1]:=RptGridM.Cells[8,i];
        ThreeStr[2]:=RptGridM.Cells[9,i];

        a[2]:=secondStr[0];
        a[3]:=secondStr[1];
        a[4]:=secondStr[2];
        a[5]:=secondStr[3];
        a[6]:=secondStr[4];

  end;

        a[7]:=ThreeStr[0];
        a[8]:=ThreeStr[1];
        a[9]:=ThreeStr[2];

        with ADOQuery1 do begin
           SQL.Clear;
           SQL.Add('INSERT INTO Rpt(YMD_date, Numb, X1, X2, X3, X4, X5, SSum, Aavg, Rang) ');
           SQL.Add('VALUES ');
           SQL.Add('(:Test1, :Test2, :Test3, :Test4, :Test5, :Test6, :Test7, :Test8, :Test9, :Test10)');
           Parameters.ParamByName('Test1').Value := a[0];
           Parameters.ParamByName('Test2').Value := a[1];
           Parameters.ParamByName('Test3').Value := a[2];
           Parameters.ParamByName('Test4').Value := a[3];
           Parameters.ParamByName('Test5').Value := a[4];
           Parameters.ParamByName('Test6').Value := a[5];
           Parameters.ParamByName('Test7').Value := a[6];
           Parameters.ParamByName('Test8').Value := a[7];
           Parameters.ParamByName('Test9').Value := a[8];
           Parameters.ParamByName('Test10').Value := a[9];
           ExecSQL;
        end;




{ADOQuery1.SQL.Text:='';
ADOQuery1.SQL.Text:='insert into Rpt (YMD_date, Numb, X1, X2, X3, X4, X5, SSum, Aavg, Rang) values(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9])';

ADOQuery1.ExecSQL;
}
end;


동적으로 MDB를 만들었습니다.

그리고 ADO쿼리로 테이블을 생성했습니다.

그리고 데이타들을 수치한 후

다시 쿼리의 SQL문을 클리어 하고 인서트 명령을 주었습니다..

안들어가 집니다..

오류 메시지가 "인벨리드 포인트 오퍼레이션!!!" ㅡ,.ㅡ

뜨는군요...(실행파일 실행시켰을때)..

ADO쿼리는 한번밖에 못쓰는 건가요?

또다른 컨포가 필요한건지요...

답 부탁 드립니다.
1  COMMENTS
  • Profile
    박상기 2003.08.30 00:43


    여러번 사용 가능합니다.
    한번 쓰고 닫아주고 SQL문장을 클리어 해주시고 열고
    이런식으로 하시면 됩니다.

    위 문장에서는 열린 상태에서 다시 쿼리를 집어 넣지 않았는지 확인해주세요