2012-01-18 8 views
38

Ho provato il nuovo driver ODBC dbExpress fornito con Delphi XE2 e ho notato che TSQLMonitor non sembra funzionare. Pensando che potrei aver configurato il componente in modo errato, ho collegato un TSQLMonitor a un TSQLConnection che utilizza il driver dbExpress di MS SQL e ha funzionato come un incantesimo.C'è un trucco per usare TSQLMonitor con un TSQLConnection che usa il nuovo driver ODBC dbExpress?

Non vedo post su questo problema sul Web. Qualcun altro ha notato questo problema? Sembra essere un bug, una funzione non supportata (nessun monitoraggio su un TSQLConnection che usa il driver ODBC), o c'è un trucco per configurare TSQLMonitor in questa condizione?

+0

Hai provato utilizzando il Tracing derivato conducente? Ciò si aggiunge ai risultati di SQLMonitor e potrebbe risultare utile. Se il driver ODBC è un driver completamente nativo (come penso) potrebbe non funzionare allo stesso modo dei "vecchi" driver basati su Dll .... –

+1

Marco: Questo è un ottimo suggerimento. Dopo aver collegato TSQLConnection al driver ODBC e quindi espandendo la proprietà Driver di TSQLConnection, imposto la proprietà DelegateConnection del driver su DBXTrace. Quindi ho espanso la proprietà DelegateConnection e ho impostato TraceFile su True e TraceFile su un nome di file (tutto secondo i tuoi suggerimenti). Grazie per questa soluzione. Voglio ancora vedere se qualcuno sa come affrontare il problema TSQLMonitor. –

+0

@Marco Cantù: un po 'di argomento, ma per favore puoi considerare questo [post] (http://stackoverflow.com/questions/10147850/add-my-own-items-to-delphi-ide-insight-f6-with -in-Delphi-aperti-tools-API)? – menjaraz

risposta

1

Prova questo fuori:

procedure TForm2.Button1Click(Sender: TObject); 
begin 
    try 
    Connect; 
    SQLMonitor1.SQLConnection := SQLConnection1; 
    SQLMonitor1.Active := True; 
    ExecuteQueries; 
    SQLMonitor1.SaveToFile('D:\\Log.txt'); 
    except 
    on E: Exception do 
     ShowMessage('Exception ocurred!: ' + E.Message); 
    end; 
end; 

procedure TForm2.Connect; 
begin 
    SQLConnection1 := TSQLConnection.Create(nil); 
    SQLConnection1.ConnectionName := 'odbcinterbaseconnection'; 
    SQLConnection1.LoginPrompt := False; 
    SQLConnection1.LoadParamsOnConnect := True; 
    SQLConnection1.Connected := True; 
end; 

procedure TForm2.ExecuteQueries; 
var 
    Query: String; 
begin 
    try 
    if SQLConnection1.Connected then 
    begin 
     Query := 'CREATE TABLE ExampleTable(id INTEGER, name VARCHAR(50))'; 
     SQLConnection1.Execute(Query, nil); 
     Query := 'INSERT INTO ExampleTable VALUES(1,''test1'')'; 
     SQLConnection1.Execute(Query, nil); 
     Query := 'INSERT INTO ExampleTable VALUES(2,''test2'')'; 
     SQLConnection1.Execute(Query, nil); 
     Query := 'INSERT INTO ExampleTable VALUES(3,''test3'')'; 
     SQLConnection1.Execute(Query, nil); 
     Query := 'SELECT * FROM ExampleTable'; 
     SQLConnection1.Execute(Query, nil); 
    end; 
    except 
    on E: Exception do 
     ShowMessage('Exception ocurred!: ' + E.Message); 
    end; 
end; 
Problemi correlati