zoukankan      html  css  js  c++  java
  • 使用VSTS创建SQL Server的functions (UserDefined Function)

    没想到,头一次使用VSTS创建SQL Server的function,就遇到个大的问题,VSTS(2008)默认的function是不支持对数据库的访问,只能够对传入的几个参数进行各种操作。如:
     image

    如果在其中对数据库操作,打开一个SqlConnection,则会出问题,提示:

    A .NET Framework error occurred during execution of user defined routine or aggregate 'Your_Function':
    System.InvalidOperationException: Data access is not allowed in this context.  Either the context is a function or method not marked with DataAccessKind.Read or SystemDataAccessKind.Read, is a callback to obtain data from FillRow method of a Table Valued Function, or is a UDT validation method.

    根据错误提示,我们得知(我是google了好久才得知的),需要做DataAccess = DataAccessKind.Read, SystemDataAccess = SystemDataAccessKind.Read 这一标记,即不能只写[Microsoft.SqlServer.Server.SqlFunction] (此处为系统默认), 如果要对数据库操作,要写成 [Microsoft.SqlServer.Server.SqlFunction(DataAccess = DataAccessKind.Read, SystemDataAccess = SystemDataAccessKind.Read)], 如:

    image

  • 相关阅读:
    循环神经网络
    相似度计算(余弦距离/欧式距离)
    最常见Linux操作
    注意力机制总结
    随机打乱数组算法、蓄水池算法
    6.1 数据结构---树(遍历)
    Node.js调用C/C++
    linux中nmcli命令详解
    stylus入门使用方法
    webpack CommonsChunkPlugin详细教程
  • 原文地址:https://www.cnblogs.com/skywind/p/1148491.html
Copyright © 2011-2022 走看看