您能帮我看看那的代码出问题了吗?我试了半天,挨句在sql里试也不知道那出错了。。C#的连接代码
public string strcon = "Integrated Security=SSPI;Initial Catalog='db123';Data Source='Ghost-1383119';User ID='sa';Password='sa';Connect Timeout=0";
try
{
 SqlConnection conn = new SqlConnection(strcon);
                        conn.Open();
                        strSQL = "select id,title,keyword from web where id<120 and id>98 order by id asc";
                        SqlDataAdapter da = new SqlDataAdapter(strSQL, conn);
                        da.SelectCommand.CommandTimeout = 60000;                         da.Fill(ds, "web");
                        conn.Close();
                        n = ds.Tables["web"].Rows.Count;
                        
                        foreach (DataRow dr in ds.Tables["web"].Rows)
                        {
                            titleid = dr["id"].ToString();
                            xsort_id = dr["xsort_id"].ToString();
                            xdirect_unicode = dr["xdirect_unicode"].ToString();                            if (titleid != null)
                            {
                                titleid = titleid.ToString();
                            }
                       
long id = long.Parse(inputid);
                string strNextSQL = "select top 1 id,title,time from web where keyword='" + keyword + "' and id>" + id + " order by id asc";
                
                SqlConnection con = new SqlConnection(strcon);
                con.Open();
                SqlDataAdapter datar = new SqlDataAdapter(strPrevSQL, con);
                
                DataSet ds = new DataSet();
                datar.Fill(ds);
                previd = ds.Tables[0].Rows[1]["id"].ToString();
                prevtitle = ds.Tables[0].Rows[1]["title"].ToString();
                prevdomainurl = ds.Tables[0].Rows[1]["url"].ToString();
                prevcontent = ds.Tables[0].Rows[1]["content"].ToString();                ds = null;
 con.Close(); SqlConnection mycon = new SqlConnection(strcon); 
                mycon.Open();                long id = long.Parse(inputid);
                string strSQL = "select * from web where id=" + id;
                SqlDataReader dr = null;
                SqlCommand mycommand = new SqlCommand(strSQL, mycon);
                dr = mycommand.ExecuteReader();
                while (dr.Read())
                {
                    titleid = dr["id"].ToString();
                    title = dr["title"].ToString();
                }
                dr.Close();
                mycommand.CommandText = "update web set show_path=1 where id=" + long.Parse(inputid);   
                mycommand.ExecuteNonQuery();
                mycon.Close();      }
ds = null; }

解决方案 »

  1.   

    事件探查器里的audit和sqlserer的审计功能应该是无关的.只是指连接建立或者数据池中的连接被重用经过验证(防止被假冒)
      

  2.   

    c#不熟,没法帮你.但是你的login out的逻辑读那么大,我怀疑有未关闭的指针等
    在ado支持max pool size,需要你在连接字符串里设定,不过这个也不是标本兼治的方法,还是要看你的程序
      

  3.   

    是不是我重复打开sql连接的原因啊?
      

  4.   

    一个很关键的问题,楼主的系统的C/S结构的吗?建议检查一下前端程序的数据库连接设计是否合理,因为这些logon,logout都来自程序的ADO连接.
      

  5.   

    程序在xp系统sql2005开发版中就正常,在win2003系统sql2005企业版就出上面的问题。。奇怪啊