Write the first YUKON CLR in which your first yukon CLR is written (generic language runtime) stored procedure

zhaozj2021-02-16  55

Write your first implementation of a Yukon CLR (common language runtime) of the stored procedure: Suhil Srinivas translation: Zhu two original source: http: //www.c-sharpcorner.com/Longhorn/Yukon/First-CLR-Procedure. ASP Description This article describes the steps of writing and executing a stored procedure for a yukon CLR generic language. This article is also a starting point for the SQL stored procedure for developing a mixed data type. Demand Correctly Install SQL Server Yukon Beta1 Introduction Yukon is Microsoft's SQL Server latest version, one of its most important features is it and .NET integration. For more information about yukon, see YUKON FAQ. A SQL Server object written in a .NET compatible language is called a .NET routine. One .NET routine can be the following type 1. Storage procedure? 2. User Define Scalar value function? 3. User-defined function value type function? 4. User-defined trigger one .NET stored procedure and early SQL stored procedure There is no difference in use. In earlier versions of SQL Server, the stored procedure is a batch or multiple batch T-SQL statement. One .NET stored procedure can be composed of T-SQL and .NET compatible languages. Writing your first .NET routine contains the following steps (based on this article, I use C # as a .NET development language): 1. Create a class and reference system.data.sqlserver and system.data.sql 2. Open Implementing business logic in the method 3. Compile this C # program with the command line tool or Visual Studio.net 4. Register this C # assembly using the database 5. Register this .NET routine 6. Using the .NET routine based on this article We develop a stored procedure as our first .NET routine. You can use Visual Studio.net or your favorite text editor to write this C # program. The program code is as follows and there is a product table in the database.

using System.Data.Sql; using System.Data.SqlServer;.?? /// /// This is my first .NET routine /// public class MyNETRoutines {public static void FirstProc () {SqlPipe myPipe = SqlContext.GetPipe (); mypipe.send ("Hello World"); SQLCOMMAND CMD = SqlContext.getCommand (); cmd.commandtext = "Select * from product"; mypipe.send (cmd.executeReader ());}} Let me Line explains the code above. All classes required for development .NET routines are system.data.sqlserver and system.data.sql namespace. These namespaces include classes such as SqlContext, which can be used to access SQL Server. You need a connection and a connection string as you don't like ADO.NET. Because the assembly is loaded into the database, it is not necessary to display a connection. One .NET routine can use In-Process Managed Provider to access SQL Server resources. The namespace mentioned above contains the implementation of in-Process Managed Provider. In this article we focus on two classes: SqlContext and sqlpipe. A SQLContext class contains a method to get a database instance connection, command, and more. SQLPIPE users implements a lot of similarities to send query results and messages to the client, and the Response class in ADO.NET. Sqlpipe.send () has four overload forms, this method is used to communicate with the client, the method of overloading is as follows: 1. Sqlpipe.send (SQLPIPE.SEND (SQLERROR SE) 3. Sqlpipe.send (IsqlRecord Record) 4. Sqlpipe.send (IsqlReader Reader) You can send a message, Reader, Error or Record to the client program. Send (String) and Send (Reader) Different points are: In SQL Server's workspace, Message is sent to the message pane, Reader sends to the Results pane. In yukon beta, the program is called SQLACCESS.DLL in YUKON BETA, and can compile the above code under the command prompt: csc.exe / T: library /r:"/sqlaccess.dll "/out:mynetRoutines.dll mynetroutines.cs? Once the program is generated, the assembly mynetroyaltys.dll contains this stored procedure, and the following code is used to perform this stored procedure.

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

New Post(0)