“/”应用程序中的服务器错误。
--------------------------------------------------------------------------------编译错误 
说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。 编译器错误信息: CS1513: 应输入 }源错误:行 169:            #line default
行 170:            #line hidden
行 171:        }
行 172:        
行 173:        private System.Web.UI.Control __BuildControl__control4() {
源文件: c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\root\68150014\e8d1396e\bnnd0zwl.0.cs    行: 171 
我的shownews.aspx代码如下:<%@ Page Inherits="news.News_show" Src="shownews.aspx.cs" %> 
<html>
<head>
<title>显示新闻</title>
<metal http-equive="Content-Type" content="text/html; charset=gb2312">
</head>
<link rel="stylesheet" href="Style.css" type="text/css">
<body bgcolor="#ffffff" text="#000000">
<table width="90%" border="0" align="center">
   <tr>
     <td>
     <div align="center"><asp:adrotator AdvertisementFile="ads.xml" bordercolor="black" borderwidth=0 runat="server" /></div>
     </td>
   </tr>
   <tr><td>&nbsp;</td></tr>
</table>
<table width="98%" border="1" cellspacing="0" cellpadding="0" bordercolordark="#FFFFFF" bordercolorlight="#006B9F" align="center">
  <tr>
    <td>
       <table width="100%" border="0">
         <tr>
            <td><font color="#FF8000> 我的新闻 </font></td>
            <td>
              <div align="right"><img src="printer.gif" width="16" height="14"><a href="javascript:window.print()">打印本页</a></div>
            </td>
         </tr>
       </table>
     </td>
  </tr>
  <tr>
    <td height="35">
       <table width="100%" border="0">
         <tr>
            <td><div align="center"><font size="3"><b><%#FormatString(dr["biaoti"].ToString()).ToString()%></b></font></div>
            </td>
         </tr>
         <tr>
           <td><div align="center"><%# if (dr["img"].ToString()!="") {%><img src='file/<%# dr["img"] %>'><%}%></div>
           </td>
         </tr>
         <tr><td><%#FormatString(dr["neirong"].ToString()).ToString()%></td>
         </tr>
         <tr><td><div align="right"><%#dr["shijian"]%></div></td></tr>
         <tr>
            <td><div align="right"><%#FormatString(dr["zuozhe"].ToString()).ToString()%></div></td>
         </tr>
       </table>
      </td> 
   </tr>         
   <tr>
      <td>
        <table width="100%" border="0">
          <tr>
             <td width="24%"><font color="#0000FF"> 浏览 </font><font color=red><%#dr["click"]%></font><font color="#0000FF">次</font></td>
             <td width="50%">
                <div align="center"><img src="email.gif"><img src="g.gif" width="17" height="13"></div>
             </td>
             <td width="26%"><div align="right"><a href="javascript:window.close()">关闭窗口</a></div></td>
          </tr>
        </table>
       </td>
     </tr>
  </table>
</body>
</html>
                               我的shownews.aspx.cs 代码如下:using System;
using System.Data;
using System.Data.OleDb;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient; //定义命名空间和类
namespace news
{
public class News_show: Page
{
  //定义变量
  public DataRow dr;
  public String newsid;
  public void Page_Load(Object sender,EventArgs e)
  {
   newsid=Request.Params["id"];
   SqlConnection myConnection= new SqlConnection("server=127.0.0.1;database=news;User ID=sa;Password=123;");
   //创建SqlDataAdapter r对象,按照指定的查询语句获取结果
   //SqlCommand myCommand = new SqlCommand("Select * from contents where id="+newsid,myConnection);
   SqlDataAdapter myCommand = new SqlDataAdapter("Select * from contents where id="+Request.Params["id"],myConnection);
   //将结果填充到一个DataSet上
   DataSet ds = new DataSet();
   myCommand.Fill(ds,"Contents");
   dr = ds.Tables["Contents"].Rows[0];
   //创建OleDbcommand对象,获取制定编号新闻的访问次数
   SqlCommand myCommand2=new SqlCommand("Select click from contents where id="+Request.Params["id"],myConnection);
       //SqlCommand myCommand2=new SqlCommand("Select click from contents where id="+newsid,myConnection);
   myCommand2.Connection.Open();
   SqlDataReader reader = myCommand2.ExecuteReader();
   reader.Read();
   //将访问次数转化为整数,然后加1
   int i = reader.GetInt32(0);
   i++;
   reader.Close();
   //重新定义SQL语句,更新访问次数
   myCommand2.CommandText = "Update contents set click="+i.ToString()+"where id="+Request.Params["id"];
   myCommand2.ExecuteNonQuery();
   myCommand2.Connection.Close();
   myConnection.Close();
  }  public string FormatString(string str)
  {
   str=str.Replace(" ","&nbsp;&nbsp;");
   str=str.Replace("<","&lt;");
   str=str.Replace(">","&gt;");
   str=str.Replace('\n'.ToString(),"<br>");
   return str;
  }
}
}
以上是我的 asp.net (C#) 程序,可就是出现以上那个错误,找不出原因,请帮帮忙!谢谢.

解决方案 »

  1.   

    ……我不是什么高手……如果说错了请见谅……
    我在学校做过类似的例子,发现这段代码里缺少myConnection.Open()方法,不知道是漏贴了,还是没有
    另外
    //SqlCommand myCommand = new SqlCommand("Select * from contents where id="+newsid,myConnection);
       SqlDataAdapter myCommand = new SqlDataAdapter("Select * from contents where id="+Request.Params["id"],myConnection);这段代码改成这样试试 SqlCommand myCommand = new SqlDataAdapter("Select * from contents where id="+Request.Params["id"],myConnection);
    SqlDataAdapter myDataAdapter = new SqlDataAdapter("Select * from contents where id="+Request.Params["id"],myConnection);
      

  2.   

    首先,谢谢你的回答,但刚才改成你这样的,则出现如下错:译错误 
    说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。 编译器错误信息: CS0029: 无法将类型“System.Data.SqlClient.SqlDataAdapter”隐式转换为“System.Data.SqlClient.SqlCommand”源错误: 行 22:  //SqlCommand myCommand = new SqlCommand("Select * from contents where id="+newsid,myConnection);
    行 23:  //SqlDataAdapter myCommand = new SqlDataAdapter("Select * from contents where id="+Request.Params["id"],myConnection);
    行 24:  SqlCommand myCommand = new SqlDataAdapter("Select * from contents where id="+Request.Params["id"],myConnection);
    行 25:  SqlDataAdapter myDataAdapter = new SqlDataAdapter("Select * from contents where id="+Request.Params["id"],myConnection);
    行 26:  //将结果填充到一个DataSet上
     源文件: F:\aspnet\shownews.aspx.cs    行: 24 请再帮忙!
      

  3.   

    SqlCommand myCommand = new SqlDataAdapter("Select * from contents where id="+Request.Params["id"],myConnection);
    晕,这句错了SqlCommand myCommand = new SqlCommand("Select * from contents where id="+Request.Params["id"],myConnection);
    试试吧
      

  4.   

    我的做法是:
    string selectstr=("Select * from contents where id='"+Request.Params["id"].ToString().Trim()+"'";
    然后:
    SqlCommand com1=new SqlCommand(selectstr,myConnection);
      

  5.   

    c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\访问权限有问题,如果你是管理员,可以在该目录的属性加上everyone用户,付给他所有权限即可,具体做法:属性—>安全->add->加上evertone用户,
      

  6.   

    忧郁的水瓶座,还是有错呀!编译错误 
    说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。 编译器错误信息: CS0117: “System.Data.SqlClient.SqlCommand”并不包含对“Fill”的定义源错误: 行 26:  //将结果填充到一个DataSet上
    行 27:  DataSet ds = new DataSet();
    行 28:  myCommand.Fill(ds,"Contents");
    行 29:  dr = ds.Tables["Contents"].Rows[0];
    行 30:  //创建OleDbcommand对象,获取制定编号新闻的访问次数
     源文件: F:\aspnet\shownews.aspx.cs    行: 28 请再帮帮! 谢谢!
      

  7.   


    vs2003有智能跟踪呀!!!你的代码SqlCommand myCommand = new SqlDataAdapter是怎么得来的?
    SqlCommand com1=new SqlCommand(selectstr,myConnection);
    SqlCommand怎么会用到Fill()呢?
    SqlCommand应该使用:
                               conn.Open();
    com1.ExecuteNonQuery();
    conn.Close();
    Fill()应该使用在:
    SqlConnection conn=new SqlConnection("Data Source=localhost;Initial Catalog=database;uid=sa");
    SqlDataAdapter newda=new SqlDataAdapter(selstr,conn);
    DataSet newds=new DataSet();
    DataTable newdt=new DataTable();
    newds.Tables.Add(newdt);
    newds.Tables[0].TableName="newdt";
    newda.Fill(newds,"newdt");
      

  8.   

    我的shownes.aspx 代码如下:
    <%@ Page Inherits="news.News_show" Src="shownews.aspx.cs" %> 
    <html>
    <head>
    <title>显示新闻</title>
    <metal http-equive="Content-Type" content="text/html; charset=gb2312">
    </head>
    <link rel="stylesheet" href="Style.css" type="text/css">
    <body bgcolor="#ffffff" text="#000000">
    <table width="90%" border="0" align="center">
       <tr>
         <td>
         <div align="center"><asp:adrotator AdvertisementFile="ads.xml" bordercolor="black" borderwidth=0 runat="server" /></div>
         </td>
       </tr>
       <tr><td>&nbsp;</td></tr>
    </table>
    <table width="98%" border="1" cellspacing="0" cellpadding="0" bordercolordark="#FFFFFF" bordercolorlight="#006B9F" align="center">
      <tr>
        <td>
           <table width="100%" border="0">
             <tr>
                <td><font color="#FF8000> 我的新闻 </font></td>
                <td>
                  <div align="right"><img src="printer.gif" width="16" height="14"><a href="Javascript:window.print()">打印本页</a></div>
                </td>
             </tr>
           </table>
         </td>
      </tr>
      <tr>
        <td height="35">
           <table width="100%" border="0">
             <tr>
                <td><div align="center"><font size="3"><b><%#FormatString(dr["biaoti"].ToString()).ToString()%></b></font></div>
                </td>
             </tr>
             <tr>
               <td><div align="center"><%# if (dr["img"].ToString()!="") {%><img src='file/<%# dr["img"] %>'><%}%></div>
               </td>
             </tr>
             <tr><td><%#FormatString(dr["neirong"].ToString()).ToString()%></td>
             </tr>
             <tr><td><div align="right"><%#dr["shijian"]%></div></td></tr>
             <tr>
                <td><div align="right"><%#FormatString(dr["zuozhe"].ToString()).ToString()%></div></td>
             </tr>
           </table>
          </td> 
       </tr>         
       <tr>
          <td>
            <table width="100%" border="0">
              <tr>
                 <td width="24%"><font color="#0000FF"> 浏览 </font><font color=red><%#dr["click"]%></font><font color="#0000FF">次</font></td>
                 <td width="50%">
                    <div align="center"><img src="email.gif"><img src="g.gif" width="17" height="13"></div>
                 </td>
                 <td width="26%"><div align="right"><a href="Javascript:window.close()">关闭窗口</a></div></td>
              </tr>
            </table>
           </td>
         </tr>
      </table>
     </body>
     </html>
                                   
                  
    我的shownes.aspx.cs 代码如下:using System;
    using System.Data;
    using System.Data.OleDb;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;
    using System.Data.SqlClient; //定义命名空间和类
    namespace news
    {
    public class News_show: Page
    {
    //定义变量
    public DataRow dr;
    public String newsid;
    public void Page_Load(Object sender,EventArgs e)
    {
    newsid=Request.Params["id"];
    SqlConnection conn= new SqlConnection("server=127.0.0.1;database=news;User ID=sa;Password=123;");
    //创建SqlDataAdapter对象,按照指定的查询语句获取结果
    SqlDataAdapter newda = new SqlDataAdapter("Select * from contents where id="+Request.Params["id"],conn);
    //将结果填充到一个DataSet上
    DataSet newds = new DataSet();
    DataTable newdt=new DataTable();
    newds.Tables.Add(newdt);
    newds.Tables[0].TableName="newdt";
    newda.Fill(newds,"newdt"); //newda.Fill(newds,"Contents");
    //dr = newds.Tables["Contents"].Rows[0];
    //创建SqlCommand对象,获取制定编号新闻的访问次数
    SqlCommand myCommand2=new SqlCommand("Select click from contents where id="+Request.Params["id"],conn);
          //SqlCommand myCommand2=new SqlCommand("Select click from contents where id="+newsid,myConnection);
    myCommand2.Connection.Open();
    SqlDataReader reader = myCommand2.ExecuteReader();
    reader.Read();
    //将访问次数转化为整数,然后加1
    int i = reader.GetInt32(0);
    i++;
    reader.Close();
    //重新定义SQL语句,更新访问次数
    myCommand2.CommandText = "Update contents set click="+i.ToString()+"where id="+Request.Params["id"];
    myCommand2.ExecuteNonQuery();
    myCommand2.Connection.Close();
    conn.Close();
    } public string FormatString(string str)
    {
    str=str.Replace(" ","&nbsp;&nbsp;");
    str=str.Replace("<","&lt;");
    str=str.Replace(">","&gt;");
    str=str.Replace('\n'.ToString(),"<br>");
    return str;
    }
    }
    }以上是我的shownews.aspx 和 shownews.aspx.cs 代码,可现在运行出现如下错误:编译错误 
    说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。 编译器错误信息: CS1513: 应输入 }源错误: 行 169:            #line default
    行 170:            #line hidden
    行 171:        }
    行 172:        
    行 173:        private System.Web.UI.Control __BuildControl__control4() {
     源文件: c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\root\68150014\e8d1396e\tn3qi0ys.0.cs    行: 171 
    神啊!!!!救救我,我到底要如何才能更正好!!!!已经两天多了!!!!!