Takes you through the process of locally 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
- Phase 1: Set Breakpoints
- To debug from the COBOL client console application into the stored procedure code, you must have a breakpoint set in both the console application code and the stored procedure code. The console application breakpoint is required to access the code in the stored procedure.
- 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 2: 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. If you want to learn how to debug a SQL CLR stored procedure remotely in a development environment, continue to
Tutorial: Debug Remotely in a Development Environment.