Takes you through the process of remotely debugging your published stored procedure in a development environment.
Note: When connecting to your SQL Server, if Microsoft SQL Server 2012 prompts you with an Attach Security Warning, please click
Attach to clear the prompt.
- Requirements
- Before attempting this tutorial, you must complete the following tutorials in the order listed:
- Tutorial: Enable SQL CLR Integration
- Tutorial: Create a Sample Database
- Tutorial: Create and Configure a Database Project
- Tutorial: Create an ADO.NET Connection
- Tutorial: Code a SQL CLR Stored Procedure using OpenESQL Assistant
- Tutorial: Publish, Debug, and Execute a Stored Procedure
- Tutorial: Call a Published Stored Procedure
- Tutorial: Prepare to Debug in a Development Environment
In addition, you must be able to run the Microsoft Remote Debugging Monitor (msvsmon.exe) on the remote machine. To do this, install the Microsoft Visual Studio Remote Debugger on the remote machine. You can download this software from the Microsoft Web site.
- Phase 1: Configure a Connection on the Development Machine
- When you created the SQLCLRTutorial connection in the ADO.NET Connection Editor, you specified the local SQL Server instance name on your development machine, represented by a "."(dot). You must change this to use a SQL Server instance on a remote machine.
- Click
Start > All Programs > Micro Focus Enterprise Developer > Data Tools > Data Connections > ADO.NET Connection Editor.
Important: If UAC is enabled, start the ADO.NET Connection Editor as an administrator. To do this, right-click the
ADO.NET Connection Editor entry specified in this step, and select
Run as administrator.
- Select the
SQLCLRTutorial connection.
- Change the value of the
Data Source key to point to a SQL Server instance on a remote machine.
- Do one of the following to set authentication for this SQL Server instance:
- If you want to connect using Windows authentication (recommended), change the value for the
Integrated Security key to
True.
- If you want to connect by providing SQL Server-specific login credentials, type your SQL Server user ID and password into the
Value fields for the
User ID and
Password keys respectively.
- Save the connection and close the ADO.NET Connection Editor.
- Phase 2: Set Properties for the SQLCLRTutorial.Publish Project
-
- From the Solution Explorer in Visual Studio, open the properties for the
SQLCLRTutorial.Publish project.
- On the
Debug tab, click
Edit in the
Target Connection String group.
- In the
Server name field, type the name of your remote SQL Server instance.
- If necessary, make authentication changes to the information in the
Log on to the server group.
- Click
OK to save the changes; then save the solution.
- Phase 3: Configure Firewall Settings on the Development Machine
-
Note: See your Microsoft documentation or your firewall vendor documentation for details on opening firewall ports.
Open the following firewall ports:
- TCP: 135 - required
- UDP: 500 and 4500 - required when your domain policy requires that network communication be performed through IPSec.
- Phase 4: Configure Firewall Settings on the Remote Machine
-
Note: See your Microsoft documentation or your firewall vendor documentation for details on opening firewall ports.
Open the following firewall ports:
- TCP: 135, 139, 455 - required
- UDP: 137, 138 - required
- UDP: 500 and 4500 - required when your domain policy requires that network communication be performed through IPSec
- TCP: 80 - required for Web Server debugging
- Phase 5: Set Up Symbol Files on the Remote Machine
- To debug a managed application remotely, the most recently generated debug symbol files for the application running on the development machine must exist on the same path(s) on the remote machine. These include the
.pdb and
.idy files.
Note: Native applications require the debug symbol files to be located on the Visual Studio host computer.
- On the development machine, build the application.
- Copy the resulting
.pdb and
.idy files from the development machine to the same directory or directories on the remote machine.
- Phase 6: Set Permissions
- You must set the appropriate permissions on the remote machine to enable the development machine to access it. For complete information regarding permissions, see the Microsoft Web site.
- Phase 7: Install
Enterprise Developer on the Remote Machine
- To successfully debug any application remotely, you must install the same version of
Enterprise Developer on the remote machine as you have installed and running on the development machine.
Note: Installing
Enterprise Server alone on the remote machine is not sufficient to remotely debug into COBOL SQL CLR stored procedures. You must install
Enterprise Developer.
- Phase 8: Start the Remote Debugging Monitor
- Because you are debugging a 32-bit application, you must start the 32-bit version of the Microsoft Remote Debugging Monitor (msvsmon.exe), available from the
Start menu.
Also, if UAC is enabled on the remote machine, you must start the Microsoft Remote Debugging Monitor as an administrator.
- Phase 9: Set Breakpoints
- To debug on the remote machine from the development machine, you must have a breakpoint set in both the console application code and the stored procedure code on the development machine. The console application breakpoint is required to access the code in the stored procedure. On the development machine:
- If you have closed the
SQLCLRTutorial solution, open it again.
- From the Solution Explorer, double-click the
Program1.cbl program to open it in the editor.
- Insert a breakpoint on the following lines of code:
:spReturnCode = call "SQLCLRturorial" (:empid INOUT, :lastname OUT, :firstname OUT)
and
goback.
- From the Solution Explorer, double-click the
SQLCLRTutorial.cbl program to open it in the editor.
- Insert a breakpoint on the following EXEC SQL statement:
EXEC SQL
SELECT
A.EMPNO
,A.FIRSTNME
,A.LASTNAME
INTO
:EMP-EMPNO
,:EMP-FIRSTNME
,:EMP-LASTNAME
FROM TEST.EMP A
WHERE (A.EMPNO = :EMP-EMPNO)
END-EXEC
- Phase 10: Run the Application
-
- Press
F5 to start the debugger.
- When the debugger hits the first breakpoint in the
Program1.cbl program, press
F5 again to execute the
SQLCLRTutorial.cbl stored procedure.
- While executing the
SQLCLRTutorial.cbl stored procedure, optionally step through line by line or examine variables as you would during any debugging process.
When the debugger hits the breakpoint on the
goback statement, the following appears in the Output window as a result of calling the stored procedure:
User = MICHAEL THOMPSON
- Press
F5 to stop debugging.
This concludes this series of SQL CLR Integration tutorials.