| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1702 人关注过本帖
标题:对象名 'dbo.forsafe' 无效。
取消只看楼主 加入收藏
等待冰柠檬
Rank: 2
来 自:浙江温州
等 级:论坛游民
帖 子:208
专家分:70
注 册:2008-6-25
结帖率:66.67%
收藏
已结贴  问题点数:20 回复次数:0 
对象名 'dbo.forsafe' 无效。
图片附件: 游客没有浏览图片的权限,请 登录注册

输入用户名点击"搜索",就出现对象名 'dbo.forsafe' 无效。输入注册时间就不会

CS代码
程序代码:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using DataCommon;
using Common;

public partial class admin_UserInfoManager : System.Web.UI.Page
{
    int pageindex = 1;
    int pagesize = PageFoot.PageSize;
    string sort = string.Empty;
    string searchkey = string.Empty;
    string starttime = string.Empty;
    string endtime = string.Empty;
    protected void Page_Load(object sender, EventArgs e)
    {
        int.TryParse(Request.QueryString["pageindex"], out pageindex);
        searchkey = PubCommon.GetQueryString("searchkey");
        starttime = PubCommon.GetQueryStringTime("starttime");
        endtime = PubCommon.GetQueryStringTime("endtime");
        if (pageindex < 1)
            pageindex = 1;
        if (!Page.IsPostBack)
        {
            int docount = 0;
            Repeater1.DataSource = SqlHelper.GetListPage(pagesize, pageindex, ref docount, sort, searchkey, starttime, endtime, "UserInfo_select");
            Repeater1.DataBind();
            foot.InnerHtml = PageFoot.PageSatte(pagesize, pageindex, docount, PageFoot.GetPageUrl(), 1);
        }
    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        try
        {
            LinkButton lb = (LinkButton)sender;
            int id = 0;
            int.TryParse(, out id);
            int i = UserInfo.Delete(id);
            if (i > 0)
            {
                MBox.RefUrl(2);
            }
            else
            {
                Response.Redirect("../Error.aspx");
            }
        }
        catch
        {
            Response.Redirect("../Error.aspx");
        }
    }
    protected void btnSouSuo_Click(object sender, EventArgs e)
    {
        searchkey = PubCommon.SafeRequest(txtYongHu.Text.Trim(), 0);
        starttime = txtZhuCeShiJian.Text.Trim();
        if (txtZhuCeShiJian.Text.Trim() != string.Empty)
        {
            endtime = (DateTime.Parse(txtZhuCeShiJian.Text.Trim()).AddDays(1)).ToShortDateString();
        }
        Response.Redirect("UserInfoManager.aspx?searchkey=" + searchkey + "&starttime=" + starttime + "&endtime=" + endtime);
    }
}
程序代码:
 /// <summary>
        /// 分页
        /// </summary>
        /// <param name="pagesize">每页记录数</param>
        /// <param name="pageindex">页码</param>
        /// <param name="docount">总记录数</param>
        /// <param name="sort">排序字段</param>
        /// <returns></returns>
        public static DataTable GetListPage(int pagesize, int pageindex, ref int docount, string sort, string searchkey, string starttime, string endtime, string StoredProcedureName)
        {
            SqlParameter[] parma ={
                SqlHelper.ExecuteParam("@pagesize",SqlDbType.Int,pagesize,ParameterDirection.Input),
                SqlHelper.ExecuteParam("@pageindex",SqlDbType.Int,pageindex,ParameterDirection.Input),
                SqlHelper.ExecuteParam("@docount",SqlDbType.Int,docount,ParameterDirection.Output),
                SqlHelper.ExecuteParam("@sort",SqlDbType.VarChar,sort,ParameterDirection.Input),
                SqlHelper.ExecuteParam("@searchkey",SqlDbType.VarChar,searchkey,ParameterDirection.Input),
                SqlHelper.ExecuteParam("@starttime",SqlDbType.VarChar,starttime,ParameterDirection.Input),
                SqlHelper.ExecuteParam("@endtime",SqlDbType.VarChar,endtime,ParameterDirection.Input),
          };

            DataTable dt = SqlHelper.ExecuteDataTable(CommandType.StoredProcedure, StoredProcedureName, parma);
            int.TryParse(parma[2].Value.ToString(), out docount);
            return dt;
        }
存储过程
程序代码:
CREATE PROCEDURE UserInfo_select
@pagesize int,
@pageindex int,
@docount int output,
@sort varchar(50)='',
@state int=0,
@type int=0,
@searchkey varchar(50)='',
@starttime varchar(50)='',
@endtime varchar(50)=''
AS
declare @mssql varchar(4000)
declare @wheremssql varchar(8000)
declare   @R bigint, @SQL   NVARCHAR(1000)

set @mssql='select  @R=count(id) from UserInfo '

set @wheremssql=' where 1=1 ';

if(len(@searchkey)>0)
begin
    set @searchkey=dbo.forsafe(@searchkey)
    set @wheremssql=@wheremssql+' and UserName like ''%'+@searchkey+'%'''
end

if(len(@starttime)>1)
begin
    set @wheremssql=@wheremssql+' and RegistDateTime>='''+@starttime+''''
end

if(len(@endtime)>1)
begin
    set @wheremssql=@wheremssql+' and RegistDateTime<'''+@endtime+''''
end

set  @mssql=@mssql+@wheremssql

SET   @SQL=  N'  '+@mssql

exec  SP_EXECUTESQL   @SQL,  N'   @R BIGINT OUTPUT',  @R OUTPUT
set @docount=@R


set @mssql=' '

set nocount on
Declare @PageLowerBound int
Declare @PageUpperBound int
set @PageLowerBound=(@pageindex-1)*@pagesize
set @PageUpperBound=@PageLowerBound+@pagesize
set rowcount @PageUpperBound--取多少条记录
set @mssql='declare @indextable table(id int identity(1,1),nid int) insert into @indextable(nid) select id from UserInfo'


set  @mssql=@mssql+@wheremssql

if(len(@sort)<1)
    set @mssql=@mssql+'    order by id desc'
else
    set @mssql=@mssql+'  order by '+ @sort

set @mssql=@mssql+ '      select * from UserInfo O,@indextable t where O.[id]=t.nid and t.id>'+cast(@PageLowerBound as varchar)+' and t.id<='+cast(@PageUpperBound as varchar)+' order by t.id'
--print(@mssql)
exec(@mssql)

set nocount off
   
    RETURN
GO
希望高手帮忙解决下!
搜索更多相关主题的帖子: dbo forsafe 对象 
2010-05-15 15:34
快速回复:对象名 'dbo.forsafe' 无效。
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.027105 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved