将参数传递给SQL MIN()函数 [英] passing a parameter to SQL MIN() function
本文介绍了将参数传递给SQL MIN()函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从ASP我运行查询使用MIN(some_field /参数)
现在我需要将此参数传递给ASP代码的查询
我该怎么做?
语法如
MIN([some_field] / [])
不起作用>
From ASP I run a query using MIN(some_field/parameter)
Now I need to pass this parameter to the query from ASP code
How do I do that?
Syntax like
MIN([some_field] / [])
does not work
推荐答案
您的意思是
MIN(some_column)/参数
?
由于参数对于查询中的所有行都是常量,这应该是
得到相同的答案。
-
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
< aa>在消息新闻中写道:呃************** @ TK2MSFTNGP11.phx.gbl ...
Did you mean
MIN(some_column) / parameter
?
Since the parameter becomes constant for all rows in the query, this should
yield the same answer.
--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
<aa> wrote in message news:er**************@TK2MSFTNGP11.phx.gbl...
从ASP我用MIN运行一个查询(some_field /参数)
现在我需要将此参数传递给ASP代码的查询
我该怎么做?
语法如
MIN([some_field] / [])
不起作用
From ASP I run a query using MIN(some_field/parameter)
Now I need to pass this parameter to the query from ASP code
How do I do that?
Syntax like
MIN([some_field] / [])
does not work
aa写道:
从ASP我运行一个查询使用MIN(some_field /参数)
现在我需要将此参数传递给ASP代码的查询
我该怎么做?
语法如
MIN([some_field] / [])
不起作用
From ASP I run a query using MIN(some_field/parameter)
Now I need to pass this parameter to the query from ASP code
How do I do that?
Syntax like
MIN([some_field] / [])
does not work
什么数据库和版本?
-
Microsoft MVP - ASP / ASP.NET
请回复新闻组。这个电子邮件帐户是我的垃圾邮件陷阱所以我
不经常检查它。如果您必须离线回复,请删除
NO SPAM
What database and version?
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don''t check it very often. If you must reply off-line, then remove the
"NO SPAM"
Dim DS As DataSet
Dim MyConnection As SqlConnection
Dim MyCommand As SqlDataAdapter
MyConnection = New SqlConnection(
" server = localhost; uid = webuser; pwd = secret; database = ShipLog")
''MyConnection = New
SqlConnection(" server =(local)\ NetSDK; database = ship log; Trusted_Connection = yes" )
MyCommand = New SqlDataAdapter(" GetCustName",MyConnection)
MyCommand.SelectCommand.CommandType = CommandType.StoredProcedure
''MyCommand.SelectCommand.Parameters.Add(New
SqlParameter(" @ CategoryName",SqlDbType.NVarChar,15))
''MyCommand。 SelectCommand.Parameters(" @CategoryName")。Value =
SelectCategory.Value
''MyCommand.SelectCommand.Parameters.Add(New SqlParameter( &曲ot; @ OrdYear",
SqlDbType.NVarChar,4))
''MyCommand.SelectCommand.Parameters(" @ OrdYear")。Val ue =
SelectYear.Value
DS =新数据集()
MyCommand.Fill(DS,客户)
''Dim anyRow as DataRow = .NewRow
''anyRow(" CUST_NAME")=" Jay"
Dim workRow As DataRow = DS.Tables
Dim DS As DataSet
Dim MyConnection As SqlConnection
Dim MyCommand As SqlDataAdapter
MyConnection = New SqlConnection(
"server=localhost;uid=webuser;pwd=secret;database= ShipLog" )
''MyConnection = New
SqlConnection("server=(local)\NetSDK;database=ship log;Trusted_Connection=yes")
MyCommand = New SqlDataAdapter("GetCustName", MyConnection)
MyCommand.SelectCommand.CommandType = CommandType.StoredProcedure
''MyCommand.SelectCommand.Parameters.Add(New
SqlParameter("@CategoryName", SqlDbType.NVarChar, 15))
''MyCommand.SelectCommand.Parameters("@CategoryName ").Value =
SelectCategory.Value
''MyCommand.SelectCommand.Parameters.Add(New SqlParameter("@OrdYear",
SqlDbType.NVarChar, 4))
'' MyCommand.SelectCommand.Parameters("@OrdYear").Val ue =
SelectYear.Value
DS = new DataSet()
MyCommand.Fill(DS, "Customer")
''Dim anyRow as DataRow =.NewRow
''anyRow("CUST_NAME") = "Jay"
''DS.Tables("Customer").Add(anyRow)
Dim workRow As DataRow = DS.Tables
这篇关于将参数传递给SQL MIN()函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文