Database Reference
In-Depth Information
Figure 20-6.
Showing Visual Studio after adding the SQL CLR C# stored procedure
5.
Replace the code in the StoredProcedure class with the code in Listing 20-1.
Listing 20-1.
SQLCLRStoredProcedure.cs
[Microsoft.SqlServer.Server.SqlProcedure()]
public static void InsertCurrency_CS(SqlString currencyCode, SqlString currencyName)
{
SqlConnection conn = null;
try
{
conn = new SqlConnection(@"server = .\sql2012;integrated security = true;
database = AdventureWorks");
SqlCommand cmdInsertCurrency = new SqlCommand();
cmdInsertCurrency.Connection = conn;
SqlParameter parmCurrencyCode = new SqlParameter
("@CCode", SqlDbType.NVarChar, 3);
SqlParameter parmCurrencyName = new SqlParameter
("@Name", SqlDbType.NVarChar, 50);