昨天有学习《http://www.cnblogs.com/insus/p/4371762.html,知道怎样创建以及布署至SQL中去。

下面这个范例是实现CLR存储过程附带参数:
带参数的CLR存储过程


可复制代码:

SqlConnection connection = new SqlConnection("Context connection=true");
        connection.Open();

        SqlCommand command = new SqlCommand();
        command.Connection = connection;

        string sql = "SELECT [Fruit_nbr],[FruitKind_nbr],[FruitName] FROM [dbo].[Fruit] WHERE [FruitName] LIKE @FruitName";   
        

        command.CommandText = sql;

        SqlParameter param = new SqlParameter("@FruitName", SqlDbType.NVarChar);
        param.Value = name;
        command.Parameters.Add(param);

        try
        {            
            SqlDataReader reader = command.ExecuteReader();
            SqlContext.Pipe.Send(reader);
        }
        catch  (Exception ex)  
        {
            throw new Exception(ex.Message);
        }       
        connection.Close();
View Code

相关文章:

  • 2022-12-23
  • 2021-10-25
  • 2022-12-23
  • 2021-05-29
  • 2022-01-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-04-02
  • 2022-12-23
  • 2022-12-23
  • 2021-08-04
  • 2021-07-27
  • 2022-12-23
相关资源
相似解决方案