Thema: Delphi Von ADOQuery zu ADSQuery

Einzelnen Beitrag anzeigen

Benutzerbild von Kevin
Kevin

Registriert seit: 11. Feb 2004
Ort: Bonn
576 Beiträge
 
Delphi 2006 Professional
 
#10

Re: Von ADOQuery zu ADSQuery

  Alt 26. Mai 2004, 22:50
Zitat von r_kerber:
Zitat von Kevin:
Die Query schreibt doch lediglich die Daten des StringGrids in eine Table. Dazu brauche ich doch beides, oder nicht?
In eine Tabelle ja, aber nicht unbedingt in ADSTable.
In was für eine Tabelle denn sonst?


Zitat von r_kerber:
Zitat von Kevin:
Nun hängt er halt an den undefinierten 'Parameters' und 'ParamValues'...
Wie sieht Dein SQL-Statement aus?
Im Prinzip so wie das Beispiel oben:

Code:
  aQry:=TADSQuery.Create(nil);
  try
    aQry.DatabaseName:=DataModule2.ADSConnection.Name;
    aQry.SQL.Text :='INSERT INTO Import '+
          '(Feld1, Feld2, Feld3, Feld4, Feld5, '+
          ... //gekürzt  
          'Feld36)'+
          ' VALUES(:v1, :v2, :v3, :v4, :v5, :v6, :v7, :v8, :v9, :v10, '+
          ':v11, :v12, :v13, :v14, :v15, :v16, :v17, :v18, :v19, :v20, '+
          ':v21, :v22, :v23, :v24, :v25, :v26, :v27, :v28, :v29, :v30, '+
          ':v31, :v32, :v33, :v34, :v35, :v36)';
    for y:=1 to ImportGrid.RowCount -1 do
    begin
      with aQry.Parameters do
      begin
        ParamValues['v1']:=ImportGrid.Cells[0, y];
        ParamValues['v2']:=ImportGrid.Cells[1, y];
        ParamValues['v3']:=ImportGrid.Cells[2, y];
        ParamValues['v4']:=ImportGrid.Cells[3, y];
        ParamValues['v5']:=ImportGrid.Cells[4, y];
        ParamValues['v6']:=ImportGrid.Cells[5, y];
        ParamValues['v7']:=ImportGrid.Cells[6, y];
        ParamValues['v8']:=ImportGrid.Cells[7, y];
        ParamValues['v9']:=ImportGrid.Cells[8, y];
        ParamValues['v10']:=ImportGrid.Cells[9, y];
        ParamValues['v11']:=ImportGrid.Cells[10, y];
        ParamValues['v12']:=ImportGrid.Cells[11, y];
        ParamValues['v13']:=ImportGrid.Cells[12, y];
        ParamValues['v14']:=ImportGrid.Cells[13, y];
        ParamValues['v15']:=ImportGrid.Cells[14, y];
        ParamValues['v16']:=ImportGrid.Cells[15, y];
        ParamValues['v17']:=ImportGrid.Cells[16, y];
        ParamValues['v18']:=ImportGrid.Cells[17, y];
        ParamValues['v19']:=ImportGrid.Cells[18, y];
        ParamValues['v20']:=ImportGrid.Cells[19, y];
        ParamValues['v21']:=ImportGrid.Cells[20, y];
        ParamValues['v22']:=ImportGrid.Cells[21, y];
        ParamValues['v23']:=ImportGrid.Cells[22, y];
        ParamValues['v24']:=ImportGrid.Cells[23, y];
        ParamValues['v25']:=ImportGrid.Cells[24, y];
        ParamValues['v26']:=ImportGrid.Cells[25, y];
        ParamValues['v27']:=ImportGrid.Cells[26, y];
        ParamValues['v28']:=ImportGrid.Cells[27, y];
        ParamValues['v29']:=ImportGrid.Cells[28, y];
        ParamValues['v30']:=ImportGrid.Cells[29, y];
        ParamValues['v31']:=ImportGrid.Cells[30, y];
        ParamValues['v32']:=ImportGrid.Cells[31, y];
        ParamValues['v33']:=ImportGrid.Cells[32, y];
        ParamValues['v34']:=ImportGrid.Cells[31, y];
        ParamValues['v35']:=ImportGrid.Cells[32, y];
        ParamValues['v34']:=ImportGrid.Cells[33, y];
        ParamValues['v35']:=ImportGrid.Cells[34, y];
        ParamValues['v36']:=ImportGrid.Cells[35, y];
      end; // with
      aQry.ExecSQL;
    end; // for y
  finally
    aQry.Free;
  end; // try
end;
Kevin
  Mit Zitat antworten Zitat