Before you can capture SQL statements, you must select a connection for each of the DB2® databases that the .NET application uses. A separate capture file is created for each connection, and you can change the default information for each capture file.
You can capture SQL statements for all of the databases that an application uses in a single pass, or you can capture the SQL in multiple passes.
Prerequisites:
For information about enabling pureQuery, refer to one of the following information center topics:
To select the data connections for capturing
SQL statements:
The Set Up .NET Application to Optimize SQL Queries window opens.
If a data connection is not in the list, click New Connection, and then define the data connection in the Add Connection window.
If you capture SQL statements for only some data
connections at a given time, consider specifying
the names of capture files so that previous capture
information is not overwritten.
If you specify the name of a capture file, its
extension must remain .capt.
If the .NET application project does not contain an application configuration (app.config) file, the file is created and added to the project folder in the Solution Explorer. If the app.config file exists because the SQL statements were previously captured and bound, the content of the file is overwritten with the current information.
For each data connection whose Capture SQL
value you set to On in the Set Up .NET
Application to Optimize SQL Queries window, a child element
is added to the <connectionStrings> element.
A corresponding child element that contains the specific
information for the data connection is added to the
<appSettings> element.
For capture purposes, the value of a captureMode
keyword is set to ON. After you click
OK in the Set Up .NET Application to
Optimize SQL Queries window, the keyword value is set
to ON for each data connection in the
app.config file.
The following code shows the content of a sample app.config file with two data connections:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="WinApp1.Props.Settings.IBMCaptSQLConn1"
providerName="IBM.Data.DB2" />
<add name="WinApp1.Props.Settings.IBMCaptSQLConn2"
providerName="IBM.Data.DB2" />
</connectionStrings>
<appSettings>
<add key="WinApp1.Props.Settings.IBMCaptSQLConn1"
value="Database=SAMPLE1;captureMode=ON;
pureQueryXML=C:\temp\IBMCaptSQLConn1.capt;
collection=jjones;rootPkgName=PKG1" />
<add key="WinApp1.Props.Settings.IBMCaptSQLConn2"
value="Database=SAMPLE2;User ID=testuser;
Password=testpw;Server=testserver.com:50000;
Persist Security Info=True;captureMode=ON;
pureQueryXML=C:\temp\IBMCaptSQLConn2.capt;
collection=testcollection;rootPkgName=PKG2" />
</appSettings>
</configuration>
Improving Performance and Security in .NET Applications with Static SQL | Using Static SQL in .NET Applications | Capturing SQL Statements in .NET Applications