string strConnection="server=local;uid=sa;pwd=111;database=mytest";

解决方案 »

  1.   

    string tmpStr = "Data source=localhost;initial catalog=mytest;password=111;user id=sa;";
      

  2.   

    把string strConnection="server=localhost;uid=sa;pwd=111;database=mytest"; 中的
    database=mytest改成initial catalog=mytest
      

  3.   

    去掉pwd=111中的111,以超级管理员身份登陆
      

  4.   

    AllenTing() 
    你是说以administrator登陆系统吗?我一直都是这样登陆的
    上面各位兄弟说的,我都试过了,没用。我想是不是sqlserver的配置问题或者其它
      

  5.   

    这是我的:
    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 
      

  6.   

    笨笨小猪的:
    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=local;uid=sa;pwd=111;database=mytest";
    Line 5:  SqlConnection sqlcon=new SqlConnection(strConnection);
    Line 6:  sqlcon.Open();
    Line 7:  </script>
    Line 8:  
     Source File: c:\inetpub\wwwroot\lyl\test.aspx    Line: 6 
      

  7.   

    string strConnection="server=localhost;uid=sa;pwd=111;database=mytest;"; 
      

  8.   

    那你uid=sa;pwd=111这儿为什么这么设置?
      

  9.   

    零零伍的:
    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="Data source=localhost;initial catalog=mytest;password=111;user id=sa;";
    Line 5:  SqlConnection sqlcon=new SqlConnection(strConnection);
    Line 6:  sqlcon.Open();
    Line 7:  </script>
    Line 8:  
     Source File: c:\inetpub\wwwroot\lyl\test.aspx    Line: 6 
      

  10.   

    AllenTing() 安装sqlserver的时候,在sa下面的密码行输入了111
      

  11.   

    还有,我的sqlserver没有装在c盘,而是装在d盘
      

  12.   

    你安装时
    选择“混合模式(Windows身份验证和SQL身份验证)”了没??
      

  13.   

    你安装时输入了密码111的话,就需要在fxsoft.ini文件中设置PASSWORD=111
      

  14.   

    fxsoft.ini在哪个文件夹里?没找到啊
      

  15.   

    不要用localhostsql server 里没有localhost吧  都是(local)
      

  16.   

    首先要确定你的登陆Sqlserver的方式 不是集成方式,这样的话,你的 语句才可能对,建议去看一下
    www.connectionstrings.com Standard Security:(标准方式)"Data Source=Aron1;Initial Catalog=pubs;User Id=sa;Password=asdasd;" 
       - or -
    "Server=Aron1;Database=pubs;User ID=sa;Password=asdasd;Trusted_Connection=False" 
       (booth connection strings produces the same result)
     Trusted Connection:(集成方式,即信任连接)"Data Source=Aron1;Initial Catalog=pubs;Integrated Security=SSPI;" 
       - or -
    "Server=Aron1;Database=pubs;Trusted_Connection=True;" 
       (booth connection strings produces the same result)(use serverName\instanceName as Data Source to use an specifik SQLServer instance, only SQLServer2000)
      

  17.   

    说错了Standard Security:(标准方式,混合模式)"Data Source=Aron1;Initial Catalog=pubs;User Id=sa;Password=asdasd;" 
       - or -
    "Server=Aron1;Database=pubs;User ID=sa;Password=asdasd;Trusted_Connection=False" 
       (booth connection strings produces the same result) Trusted Connection:(集成方式,即信任连接)"Data Source=Aron1;Initial Catalog=pubs;Integrated Security=SSPI;" 
       - or -
    "Server=Aron1;Database=pubs;Trusted_Connection=True;" 
       (booth connection strings produces the same result)(use serverName\instanceName as Data Source to use an specifik SQLServer instance, only SQLServer2000)
      

  18.   

    你的server名在哪设置的啊?
    我不知道是不是我的设置有问题
      

  19.   

    sqlserver 也是要有客户端的
      

  20.   

    重装了一下sqlserver计算机名:lyl新建了一个实例:MYINS混合验证模式密码:111在sqlserver企业管理器里新建了数据库:test在wwwroot的lyl文件夹里新建了一个文件:datatest.aspxdatatest.aspx里的全部代码如下:<%@Import Namespace="System.Data"%>
    <%@Import Namespace="System.Data.SqlClient"%>
    <script language="c#" runat="server">
    string StrCon="Server=LYL\MYINS;Database=test;User ID=sa;Password=111;Trusted_Connection=False";
    SqlConnection SqlCon=new SqlConnection(StrCon);
    SqlCon.Open();
    </script>以下是在IE地址栏输入http://localhost/lyl/datatest.aspx并按回车后的出错信息: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: CS1009: Unrecognized escape sequenceSource Error: Line 2:  <%@Import Namespace="System.Data.SqlClient"%>
    Line 3:  <script language="c#" runat="server">
    Line 4:  string StrCon="Server=LYL\MYINS;Database=test;User ID=sa;Password=111;Trusted_Connection=False";
    Line 5:  SqlConnection SqlCon=new SqlConnection(StrCon);
    Line 6:  SqlCon.Open();
     Source File: c:\inetpub\wwwroot\lyl\datatest.aspx    Line: 4 
      

  21.   

    Compiler Error Message: CS1009: Unrecognized escape sequence
    -----------------------------------------------------------------CS1009指的是:
    无法识别的转义序列在 string 中反斜杠 (\) 的后面是一个意外的字符。编译器需要一个有效的转义符;
    所以string StrCon="Server=LYL\MYINS;Database=test;User ID=sa;Password=111;Trusted_Connection=False";
    改为string StrCon="Server=LYL\\MYINS;Database=test;User ID=sa;Password=111;Trusted_Connection=False";
      

  22.   

    尽量不要手写链接!DataAdpater不是会自动生成链接嘛!用它先生成一个,然后再参考参考嘛!
      

  23.   

    string strConnection="server=localhost;uid=sa;pwd=111;database=mytest"; 
    mytest后面少了个分号!!!
      

  24.   

    string strConnection="server=(local);uid=sa;pwd=111;database=mytest";
      

  25.   

    ·  OLE DB, OleDbConnection (.NET) 
    o  Standard Security:
    "Provider=sqloledb;Data Source=Aron1;Initial Catalog=pubs;User Id=sa;Password=asdasd;" o  Trusted Connection:
    "Provider=sqloledb;Data Source=Aron1;Initial Catalog=pubs;Integrated Security=SSPI;" 
      

  26.   

    SQL Server 
    ·  ODBC 
    o  Standard Security:
    "Driver={SQL Server};Server=Aron1;Database=pubs;Uid=sa;Pwd=asdasd;" o  Trusted connection:
    "Driver={SQL Server};Server=Aron1;Database=pubs;Trusted_Connection=yes;" o  Prompt for username and password:
    oConn.Properties("Prompt") = adPromptAlways
    oConn.Open "Driver={SQL Server};Server=Aron1;DataBase=pubs;" 
      

  27.   

    ·  SqlConnection (.NET) 
    o  Standard Security:
    "Provider=sqloledb;Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=pubs;User ID=sa;Password=asdasd;" 
    o
    "Data Source=Aron1;Initial Catalog=pubs;User Id=sa;Password=asdasd;" 
       - or -
    "Server=Aron1;Database=pubs;User ID=sa;Password=asdasd;Trusted_Connection=False" 
       (booth connection strings produces the same result)o  Trusted Connection:
    "Data Source=Aron1;Initial Catalog=pubs;Integrated Security=SSPI;" 
       - or -
    "Server=Aron1;Database=pubs;Trusted_Connection=True;" 
       (booth connection strings produces the same result)
    (use serverName\instanceName as Data Source to use an specifik SQLServer instance, only SQLServer2000)
    o  Connect via an IP address:
    "Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=pubs;User ID=sa;Password=asdasd;" 
    (DBMSSOCN=TCP/IP instead of Named Pipes, at the end of the Data Source is the port to use (1433 is the default))
    o  Declare the SqlConnection:
    C#:
    using System.Data.SqlClient;
    SqlConnection oSQLConn = new SqlConnection();
    oSQLConn.ConnectionString="my connectionstring";
    oSQLConn.Open(); 
      

  28.   

    重装SQL,选择混和认证,输入密码就可以了!!!