![]() |
Von ADOQuery zu ADSQuery
Hallo Leute,
ich brauche Hilfe beim Umstellen von Access auf ADS. Die folgende, von Gollum ![]()
Code:
// folgendes Beispiel geht einem 3-Spaltigen Stringgrid aus
var aQry:TADOQuery; y:Integer; sQry:String; ... aQry:=TADOQuery.Create(nil); try aQry.Connection:=ADOConnection1; sQry:='INSERT INTO tabelle (Feld1, Feld2, Feld3) VALUES(:v1, :v2, :v3)'; for y:=1 to StringGrid1.RowCount do begin aQry.SQL.Text:=sQry; with aQry.Parameters do begin ParamValues['v1']:=StringGrid1.Cells[0, y]; ParamValues['v2']:=StringGrid1.Cells[1, y]; ParamValues['v3']:=StringGrid1.Cells[2, y]; end; // with aQry.ExecSQL; end; // for y finally aQry.Free; end; // try Ein Durchsuchen der DP nach nahezu allen möglichen Suchbegriffen in Bezug auf ADS und Queries hat leider kein Ergebnis gebracht... Ich zähl auf Euch :thuimb: |
Re: Von ADOQuery zu ADSQuery
Wo hakt es denn?
|
Re: Von ADOQuery zu ADSQuery
Hallo r_kerber,
bei aQry.Connection:=MeineADSConnection; kommt die Fehlermeldung "Undefinierter Bezeichner: 'Connection'". Und damit kann ich auch nicht testen, ob der Rest funktioniert... :gruebel: |
Re: Von ADOQuery zu ADSQuery
Was hälts Du von aQry.DatabaseName?
|
Re: Von ADOQuery zu ADSQuery
Zitat:
für die Parameter-Objekte, da diese jedesmal aus der SQL-Anweisung geparst werden. Deshalb:
Delphi-Quellcode:
Manchmal ist ADO nicht in der Lage, die Datentypen der Parameter korrekt zu ermitteln.
aQry:=TADOQuery.Create(nil);
try aQry.Connection:=ADOConnection1; aQry.SQL.Text:='INSERT INTO tabelle (Feld1, Feld2, Feld3) VALUES(:v1, :v2, :v3)'; for y:=1 to StringGrid1.RowCount do begin (dies hängt vom OLE-DB Provider ab; auch die VCL hat hier möglicherweise noch Bugs) Dann muss man nachhelfen:
Delphi-Quellcode:
aQry.SQL.Text:='INSERT INTO tabelle (Feld1, Feld2, Feld3) VALUES(:v1, :v2, :v3)';
aQry.Parameters.ParamByName('v1').Datatype := dtInteger; ... for y:=1 to StringGrid1.RowCount do |
Re: Von ADOQuery zu ADSQuery
Zitat:
Zudem kommt noch eine weitere Fehlermeldung: "Undefinierter Bezeichner: 'parameters'". Scheint TADSQuery auch nicht zu kennen. Ich steh momentan ein wenig auf dem Schlauch und mit dem Rücken zur Wand. Entschuldigt bitte meine Extremblockade... :pale: Zitat:
die Prozedur hat aber prima ihren Dienst verrichtet. Ich werde aber Deine Vorschläge mal mit ADO testen, obwohl ich das Vertrauen in ADO so ziemlich verloren habe und im Begriff bin zu ADS/ALS zu wechseln. |
Re: Von ADOQuery zu ADSQuery
Hallo Kevin,
zunächst die Frage warum Table und Query? Eines von beiden reicht! Und jetzt, wo Du es sagst, merke ich auch, dass AdsQuery ein wenig anders arbeitet als z.B ADSTable. So hat's aber bei mir funktioniert:
Delphi-Quellcode:
AdsQuery1.DatabaseName := AdsConnectionTest.Name;
|
Re: Von ADOQuery zu ADSQuery
Zitat:
Zitat:
|
Re: Von ADOQuery zu ADSQuery
Zitat:
Zitat:
|
Re: Von ADOQuery zu ADSQuery
Zitat:
Zitat:
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; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:18 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz