asp.net:怎么用这个类方法呀?

来源:百度知道 编辑:UC知道 时间:2024/06/19 18:28:12
这是Database类里声明的两个方法,Database类是一个数据库链接类

public void RunProc(string procName, out SqlDataReader dataReader)
{
SqlCommand cmd = CreateCommand(procName, null);
dataReader = cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection);
//return (int)cmd.Parameters["ReturnValue"].Value;
}
public SqlParameter MakeInParam(string ParamName, SqlDbType DbType, int Size, object Value)
{
return MakeParam(ParamName, DbType, Size, ParameterDirection.Input, Value);
}
这是另一个类,里面有Database类里两个函数的调用:
public SqlDataReader ShowNews(string ConferenceId,string cCode)
{
string tmpsql="select Convert(char(10),MakeDate,120) as MakeDate,NewItem from gy_news where getdate()<=makedate+DelayDay+1 and
IsUnValid=0 and OrderConferenceId='"+ConferenceId+"' and ((cCode='"+cCode+"' and type=0) or type=

ShowNews 方法返回的数据绑定在GRIDVIEW和LABEL就可以了啊
SqlParameter 是执行存储过程的参数

这几个方法写得很奇怪啊,anyway,你只需要传进去指定的数据ConferenceId和cCode就可以,意义得看下sql的这段
from gy_news where getdate()<=makedate+DelayDay+1 and
IsUnValid=0 and OrderConferenceId='"+ConferenceId+"' and ((cCode='"+cCode+"' and type=0) or type=1)

返回的是reader 用法参照如下
while (reader.Read())
{
Console.WriteLine(String.Format("{0}, {1}",
reader[0], reader[1]));
}
[0],[1]代表第0 1 列