急。为什么会报这个错啊
报错:未将对象引用设置到对象的实例。
//绑定最近更新数据
在数据库中存储过程:
create proc [dbo].[proc_AllBind]
(
@Subject varchar(30)
)
as
--判断查询的信息是否存在,是返回1,否则返回-1
if exists(select * from tb_Files where Subject = @Subject)
begin
select * from tb_Files
where Subject = @Subject
return -1
end
else
return -1
在FC类里
public DataTable TopNineBind(string Subject, string TableName)
{
//GetCommandProc是执行存储过程用的。验证过没错误。放在SqlC类里
SqlCommand myCmd = SqlC.GetCommandProc("proc_TopNineBind");
myCmd.Parameters.Add(new SqlParameter("@Subject", SqlDbType.VarChar, 30));
myCmd.Parameters["@Subject"].Value = Subject;
try
{
return SqlC.GetDataSet(myCmd, TableName);
}
catch (System.Exception ex)
{
throw new Exception(ex.Message, ex);
}
}
在PageLoad里
this.DLLastupdate.DataSource = FC.TopNineBind(Subject, "file").DefaultView;
this.DLLastupdate.DataBind();
说明:当数据库里没有任何东西时会报错。Subject="CET"但数据库里没有存在此列名。
如果在数据库中执行存储过程exec proc_TopNineBind 'CET' ,返回值为-1.