在的SqlCommand调用函数 [英] Calling Functions in SqlCommand

查看:261
本文介绍了在的SqlCommand调用函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public void CreateMySqlCommand() 
 {
    SqlCommand myCommand = new SqlCommand();
    myCommand.CommandText = "SELECT * FROM Categories ORDER BY CategoryID";
    myCommand.CommandTimeout = 15;
    myCommand.CommandType = CommandType.Text;
 }



我可以使用myCommand.CommandText为什么Sql Server的功能?

Can I use Sql Server functions in myCommand.CommandText and why?

推荐答案

如果你的意思是,的 SQL Server用户定义函数的。然后,;您可以正常使用,如:

If you mean, SQL Server user defined functions. Then, yes; you can use it normally like:

myCommand.CommandText = "SELECT fn_Yourfunctionname(@parameternames)";
myCommand.CommandType = CommandType.Text;
myCommand.Parameters.Add(new SqlParameter("@parameternames", ...



它的工作原理的原因是因为这是一个函数被调用SQL Server中直接的方式。

The reason it works is because this is the way that functions are called in SQL Server directly.

这篇关于在的SqlCommand调用函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆