出错如下:
Server Error in '/' Application.
--------------------------------------------------------------------------------Compilation Error 
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: CS1519: Invalid token '(' in class, struct, or interface member declarationSource Error: Line 4:  string strConnection="server=localhost;uid=sa;pwd=111;database=mytest"; 
Line 5:  SqlConnection sqlcon=new SqlConnection(strConnection);
Line 6:  sqlcon.Open();
Line 7:  </script>
Line 8:  <style Type="Text/css">
 Source File: c:\inetpub\wwwroot\lyl\test.aspx    Line: 6 

解决方案 »

  1.   

    string strConnection="server=localhost;uid=sa;pwd=111;database=mytest"; 
    改为:
    string strConnection="server=local;uid=sa;pwd=111;database=mytest"; 
      

  2.   

    双击SqlConnection用属性设计器里的ConnectionString属性生成一个,确保可以连接上了,然后把字符串copy到那句上去。
      

  3.   

    把连接数据库代码改为 
    public void Page_Load()
     {
          string strConnection="server=localhost;uid=sa;pwd=111;database=mytest"; 
          SqlConnection sqlcon=new SqlConnection(strConnection);
          sqlcon.Open();
      }
      

  4.   

    也就是把连接代码放入Page_Load()事件中 *_*
      

  5.   

    主要还是连接字符串没有打开
      SqlConnection sqlcon=new SqlConnection(strConnection);
      

  6.   

    strConnection="server=(local);uid=sa;pwd=111;database=mytest"; 
    SqlConnection sqlcon=new SqlConnection(strConnection);
      

  7.   

    算了,偶也不知道原因但偶装了.net后就可以了。。
      

  8.   

    .NET有时是很奇怪的出现一些问题我也遇到过,大概是没装好吧!重装以后就一切OK了!
      

  9.   

    同意  gabriel1(星空微凉,泪眼汪汪,思念今日更长)  
    顶!!!!!!!!!!!!!!!!!!!!!!!
      

  10.   

    string strConnection="server='(local)';uid=sa;pwd=111;database=mytest"; 保证是这个
      

  11.   

    string strConnection= "data source=localhost;initial catalog=mytest;user id=sa;Password=111;";
    SqlConnection sqlcon=new SqlConnection(strConnection);
    sqlcon.Open();
      

  12.   

    http://dev.csdn.net/article/16/16437.shtm
    http://www.connectionstrings.com/
    http://community.csdn.net/Expert/TopicView3.asp?id=3705163