Development: Visual Studio

Following are step-by-step instructions you should follow to develop the solution. All development is done in Visual Studio 2005. Follow the relevant instructions based on your language of preference (C# or Visual Basic). Note that if you’re working with Visual Studio Professional edition or later, you have the option of working with the SQL Server Project template, which allows you to deploy the assembly and the routines in SQL Server automatically. In any edition of Visual Studio–including Standard–you can use the Class Library project template. This template will allow you to develop and build the assembly in Visual Studio, in which case you will have to follow with a manual process of deployment in SQL Server using T-SQL code. Both options are covered by the step by step instructions.

If this is the first time you’re developing .NET code in SQL Server, I’d recommend experimenting with both options.

Create Project

  1. Create a new project using your preferred language (C#/Visual Basic):

    (File>New>Project>Visual C# | Visual Basic)

  2. Choose a project template based on the Visual Studio edition.

    For the Professional or later edition:

    Use either the Database SQL Server template (Database>SQL Server Project) or the Class Library template (Class Library).

    For the Standard edition:

    Use the Class Library template (Class Library).

  3. Specify the following details in the New Project dialog box:

    Name: CLRUtilities

    Location: C: (or your folder of preference)

    Solution Name: CLRUtilities

    Confirm

  4. Create a database reference in the Add Database Reference dialog box (relevant only if you chose the SQL Server Project template).

    Create a new database reference to the CLRUtilities database, or choose an existing reference if you created one already.

    Do not confirm SQL/CLR debugging on this connection.

Develop Code

  1. Add or Rename the class.

    SQL Server Project template:

    (Project>Add Class...>Class>Name: CLRUtilities.cs | CLRUtilities.vb>Add)

    Class Library template:

    (Rename Class1.cs to CLRUtilities.cs | Class1.vb to CLRUtilities.vb)

  2. Replace the code in the class with the code from Example A-2 (C#) or Example A-3 (Visual Basic).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.106.33