“/”应用程序中的服务器错误。
--------------------------------------------------------------------------------未将对象引用设置到对象的实例。 
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。源错误: 
行 59:         if (!IsPostBack)
行 60:         {
行 61:             Socut.Data.ExecuteNonQuery("UPDATE wyx_site SET wyx_jishu=wyx_jishu+1 WHERE wyx_id=1");
行 62: 
行 63:         }
 源文件: e:\freehost\LocalUser\wzwen\www\index.aspx.cs    行: 61 堆栈跟踪: 
[NullReferenceException: 未将对象引用设置到对象的实例。]
   Socut.Data.xcc381ffa3ede662f(String xdc883b85b538bbcc) +60
   Socut.Data.x2f59d6a21691a4d1(Int32 x3146d638ec378671) +319
   Socut.Data.ExecuteNonQuery(String xd38650ca6fc38b28, String[,] x41baca1d6c0c2e8e, Int32 xd5c403e5caba3eaa) +47
   Socut.Data.ExecuteNonQuery(String x68801ba40166ebdd) +9
   index.Page_Load(Object sender, EventArgs e) in e:\freehost\LocalUser\wzwen\www\index.aspx.cs:61
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +34
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +47
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061 
--------------------------------------------------------------------------------
版本信息: Microsoft .NET Framework 版本:2.0.50727.42; ASP.NET 版本:2.0.50727.42 后台源程序:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;public partial class index : System.Web.UI.Page
{
    public string jianjie;
    public string gonggao;
    public string jishu;
        protected void Page_Load(object sender, EventArgs e)
    {
        //显示网站简介
        Socut.Reader drrr = new Socut.Reader("SELECT * FROM wyx_notice WHERE wyx_id=1");
        while (drrr.Read())    //使用while循环,表示从头一直查找到尾 
        {
            jianjie = drrr["wyx_content"].ToString();
        }
        drrr.Close();
        //显示公告
        Socut.Reader drrrr = new Socut.Reader("SELECT * FROM wyx_notice WHERE wyx_id=2");
        while (drrrr.Read())    //使用while循环,表示从头一直查找到尾 
        {
            gonggao = drrrr["wyx_content"].ToString();
        }
        drrrr.Close();
        //统计文章篇数
        int i = (int)Socut.Data.ExecuteScalar("SELECT COUNT(wyx_id) FROM wyx_text");
        Label1.Text = "共有" + i.ToString() + "篇文章";
        //显示栏目分类
        DataSet ds = Socut.Data.ExecuteDataSet("SELECT * FROM wyx_class ORDER BY wyx_classsort ASC");
        string classid = "wyx_idd";
        wyxList.DataSource = ds;  //设置数据源 
        wyxList.DataBind();       //绑定数据
        //网站访问量
        Socut.Reader drr = new Socut.Reader("SELECT * FROM wyx_site WHERE wyx_id=1");//实例化一个Socut.Reader阅读器实例
        while (drr.Read())    //使用while循环,表示从头一直查找到尾 
        {
            jishu += drr["wyx_jishu"].ToString();
        }
        drr.Close();        if (!IsPostBack)
        {
            Socut.Data.ExecuteNonQuery("UPDATE wyx_site SET wyx_jishu=wyx_jishu+1 WHERE wyx_id=1");        }
            
    }    protected void wyxList_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            //找到子Repeater控件的引用
            Repeater cr = (Repeater)e.Item.FindControl("wyxList1");
            //找到分类Repeater关联的数据项
            DataRowView rv = (DataRowView)e.Item.DataItem;
            //提取分类ID
            int wyxid = Convert.ToInt32(rv["wyx_idd"]);
            //根据分类ID查询该分类下的产品,并绑定子Repeater
            DataSet ds2 = Socut.Data.ExecuteDataSet("select top 5 * from wyx_text where wyx_class=" + wyxid + " ORDER BY wyx_id DESC");
            cr.DataSource = ds2;
            cr.DataBind();        }
    }        public string textlist()
    {
        string strBody = null;
        
        Socut.Reader dr = new Socut.Reader("SELECT * FROM wyx_text");
        while (dr.Read())    //使用while循环,表示从头一直查找到尾 
        {
            strBody += "·" + "<a href='view.aspx?id="+dr["wyx_id"]+"' target=_blank>"+dr["wyx_title"].ToString() + "</a><br>";                     //使用“+=”累加数据 
        }
        dr.Close();//
        return strBody;    }    protected void Button1_Click(object sender, EventArgs e)
    {        if (TextBox1.Text != "")
        {
            Response.Redirect("search.aspx?text=" + TextBox1.Text + "&type=" + DropDownList1.SelectedValue);
        }
    }
}

解决方案 »

  1.   

    Socut.Data.ExecuteNonQuery这个所对应的dll是不是复制到了服务器中网站的bin目录下?
      

  2.   

    我用的是Socut.Data数据库操作组件,已经拷贝上去了呀,怎么还这样呢,真是奇怪
      

  3.   

    我不用数据库组件(就是这个Socut.Data.dll),直接用代码访问数据库能正常运行,真奇怪
      

  4.   

    我也出现过这种问题, socut.data.dll 这个用来做 select 就还可以,用来做update 和 insert 就有点问题.
    我的网站: www.dzms.net
      

  5.   

    没有引入数据库的命名空间
    using system.Data.Sqlclient;