How to use the vs.net debug data stock procedure Longrujun [original]

zhaozj2021-02-16  128

VS.NET can use languages ​​such as C # and VB.NET to develop .NET architectures, can also be used to write CSS (laminated style sheets), HTML, XML, and SQL. Among them, the functionality of SQL is often neglected by us. Here I explain in detail how vs.net works with SQL. The database connection VS.NET Server Explorer can be very convenient to implement the connection with the database server. Although this connection is not limited to SQL Server. Figure A shows the Server Explorer panel on the right side of the VS.NET workspace. You can find the object via the View drop-down menu, or click the tab to display the Server Explorer on the right side of the workspace. Right-click Data Connections in Server Explorer, which will appear options to connect to the new database. Figure B is a connection dialog. Where the Test Connection button can easily test the connectionability and connection correctness of the database. Figure A: Visual Studio .NET Server Explorer Figure B: Adding a new database connection via Server Explorer Once a connection is added to Server Explorer, it will appear in the server node of Server Explorer. At the same time, the server name and related options will appear below. The SQL Servers node can provide programs to access SQL Server's capabilities of data elements. Now, you can already start debugging SQL code, but some settings are required before this. SQL Server Sets SQL Server contains an extended stored procedure that can be used to control the access capabilities of the calling process. This stored procedure is called sp_sdidebug. The following T-SQL code can be used to allow a user to debug a stored procedure: Use master grant execute on sp_sdidebug to username In addition, the user must have access to the database and stored procedures. Once you do a good job, the user can start the real debugging process. In fact, the debugging process is very simple, just right-click the stored procedure in VS.NET Server Explorer, and select Step Into Stored Procedure. Figure C is an example of a stored procedure commissioning using the Northwind database. In this example, the stored procedure returns the highest price products from the database. Figure C: By the Server Explorer debug store process When the debugging process begins, it is nothing different from the daily debug C # or VB.NET code. Figure D is the view of the stored procedure in debug mode. The corresponding option can be implemented by the debug drop-down menu or shortcut. The following is a few shortcuts related to debug-related: F5: Continue Shift F5: Stop debugging F11: Single step into the F10: Single Step Skip SHIFT F11: Single Step Jump out Figure D: The stored procedure in debug mode is additional, you can Add breakpoints and view points to monitor debugging procedures. At the bottom of the VS.NET workspace, you can see the output result of the debugging process. Figure E shows the VS.NET workspace after debugging the stored procedure. From the graph, we can see debugging information: The return value of the stored procedure run is 0, which means that the run is successful.

转载请注明原文地址:https://www.9cbs.com/read-9025.html

New Post(0)