求教存储过程的问题,在线等!

feic 2003-11-28 09:41:44
表table
字段
name char
floor int

请问?
如何使用存储过程返回floor的最大值到页面,并且返回floor=最大值的,记录数量!
如何在页面付值给floor,返回floor等于该值的记录数的数量!

谢谢
...全文
48 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
feic 2003-11-28
  • 打赏
  • 举报
回复
还是不会如何在页面上使用
HanYZ 2003-11-28
  • 打赏
  • 举报
回复
cnt 是字段别名,随便起的
调用存储过程的问题建议你查查MSDN吧
feic 2003-11-28
  • 打赏
  • 举报
回复
还有人帮忙吗/
feic 2003-11-28
  • 打赏
  • 举报
回复
还有大哥
cnt是什么东西啊?
feic 2003-11-28
  • 打赏
  • 举报
回复
那如何使用该存储过程呐?
HanYZ 2003-11-28
  • 打赏
  • 举报
回复
返回floor 最大值、记录数量
create proc spA as
select top 1 floor, cnt from
(select floor,(count)cnt from table group by floor order by floor desc) a

floor等于该值的记录数的数量
create proc spB( @x int ) as
selecte count(*) cnt from table where floor=@x
feic 2003-11-28
  • 打赏
  • 举报
回复
高手呐?
py3zhsh 2003-11-28
  • 打赏
  • 举报
回复
學習
godblessyU 2003-11-28
  • 打赏
  • 举报
回复
参数@test是返回的值
godblessyU 2003-11-28
  • 打赏
  • 举报
回复
这是我的程序写的,你看看思路:
public bool ExecAnticipate(string strYH,string strJCJ,string strFlag,string strFlag1)
{
SqlCommand insertCommand;
bool bolFlag=false;

insertCommand = new SqlCommand("createfile",new SqlConnection(AppConfig.ConnectionString));
insertCommand.Connection.Open();
insertCommand.CommandType = CommandType.StoredProcedure;

SqlParameterCollection sqlParams = insertCommand.Parameters;
sqlParams.Add(new SqlParameter(FLAG1_PARM, SqlDbType.Char,1));
sqlParams.Add(new SqlParameter(YHDM_PARM, SqlDbType.Char,2));
sqlParams.Add(new SqlParameter(JCJBM_PARM, SqlDbType.Char,2));
sqlParams.Add(new SqlParameter(FLAG_PARM, SqlDbType.Char,1));
sqlParams.Add(new SqlParameter("@test",SqlDbType.Char,1));

sqlParams["@test"].Direction = ParameterDirection.Output ;

sqlParams[YHDM_PARM].Value = strYH.Trim();
sqlParams[YHDM_PARM].Direction = ParameterDirection.Input ;

sqlParams[JCJBM_PARM].Value = strJCJ.Trim();
sqlParams[JCJBM_PARM].Direction = ParameterDirection.Input ;

if(strFlag1=="0")
{
if (strFlag=="否")
strFlag="0"; //不跨月申报
else
strFlag="1"; //跨月申报

sqlParams[FLAG1_PARM].Value = "0";
sqlParams[FLAG1_PARM].Direction = ParameterDirection.Input ;
}
else
{
sqlParams[FLAG1_PARM].Value = "1";
sqlParams[FLAG1_PARM].Direction = ParameterDirection.Input ;
}

sqlParams[FLAG_PARM].Value = strFlag;
sqlParams[FLAG_PARM].Direction = ParameterDirection.Input ;

try
{
insertCommand.ExecuteNonQuery();
insertCommand.Connection.Close();
strTest=sqlParams["@test"].Value.ToString();
bolFlag=true;
}
catch(Exception exp)
{
throw new Exception(exp.Message);
}
finally
{
insertCommand=null;
}
return bolFlag;
}

110,570

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧