条件:vs2005里面,在web应用程序里建了用户自定义控件,在网页中使用控件,控件完成excel上传,并加入到sql中 
问题: 
1、在iis下的虚拟路径浏览时,出现错误,而在本地运行是正常的,为什么啊? 
2、单步调试时,代码跳过,不执行,为什么? 
3、设置断点,在调试时,断点跳到下一行,上面一行的内容也没有执行,这又是为什么啊?

解决方案 »

  1.   

    首先要确定你的IIS有没有问题
      

  2.   

    从你的代码看没有什么问题,不知道你的
    2、单步调试时,代码跳过,不执行,为什么? 
    3、设置断点,在调试时,断点跳到下一行,上面一行的内容也没有执行,这又是为什么啊?
    是指在哪里跳掉的,如果说是在iis下访问出问题的,建议在webconfig开启显示远程错误的选项,
    <customErrors   mode="RemoteOnly"   />
    这样就能快速定位错误了
      

  3.   

    protected DataTable getExcelDate() 
            { 
                if (conn.State.ToString() == "Closed") 
                { 
                    conn.Open(); 
                }      
                string onadvance = "exec sp_configure 'show advanced options',1 reconfigure"; 
                string ondistributed = "exec sp_configure 'Ad Hoc Distributed Queries',1 reconfigure"; 
                string offadvance = "exec sp_configure 'Ad Hoc Distributed Queries',0 reconfigure"; 
                string offdistributed = "exec sp_configure 'show advanced options',0 reconfigure";                              
                        
                string thepath = Server.MapPath("~/NameList/");      
                FileUpload1.SaveAs(thepath + "\\" + FileUpload1.FileName); 
                string newpath = thepath +"\\"+ FileUpload1.FileName.ToString(); 
                string sql = "select * from OpenDataSource('MICROSOFT.JET.OLEDB.4.0','Excel 5.0;HDR=YES;DATABASE=" + newpath + "',sheet1$)";                   
                SqlCommand myCommand11 = new SqlCommand(onadvance, conn);            
                myCommand11.ExecuteNonQuery();            
                SqlCommand myCommand12 = new SqlCommand(ondistributed, conn);            
                myCommand12.ExecuteNonQuery();                        
                SqlDataAdapter da = new SqlDataAdapter(sql, conn);                                  
                DataSet ds = new DataSet();            
                da.Fill(ds);            
                    
                SqlCommand myCommand31 = new SqlCommand(offadvance, conn);                
                myCommand31.ExecuteNonQuery();                
                SqlCommand myCommand32 = new SqlCommand(offdistributed, conn);                
                myCommand32.ExecuteNonQuery();                      return ds.Tables[0]; 
            }  
    大牛~代码如上~
    NameList是我建的web应用程序文件夹下面的一个子文件夹。
    在iis上,我在所在网站下将web应用程序作为虚拟目录加进来了,虚拟目录下面的子文件夹就是:NameList
    Server.MapPath("~/NameList/")这样写没有问题吗?请赐教啊~
      

  4.   

    不进入断点,说明你调试的是该代码以前生成的程序集,而非现在生成,建议在iis设置成debug下的目录看看,如果是这问题做相应代码替换就行了。
      

  5.   

    在iis设置成debug下的目录,这个是什么意思呢?