string strConnection="server=local;uid=sa;pwd=111;database=mytest";
解决方案 »
- 请教关于 int char unicode byte 之间的转换
- C# socket.Client.Receive(Rece); 如何判断有无接收数据,并正常执行。
- 怎么调用WEB服务
- 操作office
- 在后台服务中调用控制台及时显示信息?
- 如何让test.txt文件中的数据通过hello.Exe文件
- 小问题-----如何利用存储过程insert,update表?急!!!
- 怎么才能在启动一个chm帮助文件后,再启动这个chm文件时能够检测到已经有一个在运行了,并最大化这个chm截面,象普通帮助文件一样!
- sbFileName.Replace("\", "\\");
- 如何把一个树状结构的数据包装成一个类
- 请问关於木马的问题
- htmlinputfile问题,接上帖...
database=mytest改成initial catalog=mytest
你是说以administrator登陆系统吗?我一直都是这样登陆的
上面各位兄弟说的,我都试过了,没用。我想是不是sqlserver的配置问题或者其它
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
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
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
选择“混合模式(Windows身份验证和SQL身份验证)”了没??
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)
- 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)
我不知道是不是我的设置有问题
<%@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
-----------------------------------------------------------------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";
mytest后面少了个分号!!!
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;"
· 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;"
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();