I have inherited an ASP.NET project containing a connection string with the DataSource set to:
我继承了一个ASP.NET项目,其中包含一个连接字符串,其DataSource设置为:
"Data Source=.\\\sql2008"
I have not seen anything of this type before. Can anyone explain what the .\\\
means? Also, what is the correct technical term for the part set to sql2008
?
我之前没见过这种类型的东西。任何人都可以解释一下。\\\的意思吗?另外,设置为sql2008的部件的正确技术术语是什么?
Thanks very much.
非常感谢。
4 个解决方案
#1
1
The period (.) indicated sql server is running on the same box as the asp.net application.
句点(。)表示sql server与asp.net应用程序在同一个盒子上运行。
My hunch is the connection string you posted was pulled out of a c# string literal. The \\ is really just a single slash, but you need to escape it in C# and the escape character is another \.
我的预感是您发布的连接字符串是从c#字符串文字中提取出来的。 \\实际上只是一个斜杠,但你需要在C#中转义它,转义字符是另一个\。
The sql2008 is the INSTANCE NAME. Sql server can be installed multiple times on a host. The default instance, of which there can be only one, can be reference without the \InstanceName suffix. You can have multiple NAMED INSTANCES. Using the named instance suffix in the connection string is how you designate which instance you are connecting to.
sql2008是INSTANCE NAME。 Sql server可以在主机上多次安装。默认实例(只能有一个)可以在没有\ InstanceName后缀的情况下引用。您可以拥有多个NAMED INSTANCES。在连接字符串中使用命名实例后缀是指定要连接到哪个实例的方式。
EDIT: If "datasource=sql2008" works then perhaps your server name is sql2008 and your database is installed as the default instance. You can determine if you are using a named instance by inspecting the services control panel applet. If you are using a named instance, the sql service will be listed as "SQL SERVER (MSSQLSERVER$INSTANCENAME)".
编辑:如果“datasource = sql2008”工作,那么您的服务器名称可能是sql2008,并且您的数据库是作为默认实例安装的。您可以通过检查服务控制面板小程序来确定您是否正在使用命名实例。如果您使用的是命名实例,则sql服务将列为“SQL SERVER(MSSQLSERVER $ INSTANCENAME)”。
#2
0
This refers to a local instance of sql server running upon the machine that the application is deployed upon. sql2008 is the name of the sql server that is being connected to.
这是指在部署应用程序的机器上运行的sql server的本地实例。 sql2008是要连接的sql server的名称。
#3
0
Hello I use this so if this will help you:
你好我使用这个,如果这对你有帮助:
Data Source= server_name; Initial Catalog=database_name; User ID=user_id;Password=password
or try to do so:
或尝试这样做:
Server=.\server_name;Database=database_name; User ID=user_id;Password=password
#4
0
The ". \" always means from the current position in local
“。\”总是意味着从当地的当前位置
In .NET you can escape special characters by either putting an @ in front of the string or using a special value to represent the character you want to escape. In this case you can use \ to represent a \
在.NET中,您可以通过在字符串前面放置@或使用特殊值来表示要转义的字符来转义特殊字符。在这种情况下,您可以使用\来表示\
".\\" == @".\"
“。\\”== @“。\”
So for me
所以对我来说
"Data Source=.\\SQLServer2005" equal @"Data Source=.\SQLServer2005"
“数据源=。\\ SQLServer2005”等于@“数据源=。\ SQLServer2005”
but
但
"Data Source =.\\SQLServer2005" or "Data Source =.\\\SQLServer2005"
“数据源=。\\ SQLServer2005”或“数据源=。\\\ SQLServer2005”
I do not see what that could mean ...
我不明白这意味着什么......
Do you can try this ?
你能尝试一下吗?
SqlConnection cnn ;
String connetionString = "Data Source=ServerName;Initial Catalog=DatabaseName;User ID=UserName;Password=Password"
cnn = new SqlConnection(connetionString);
try
{
cnn.Open();
MessageBox.Show ("Connection Open ! ");
cnn.Close();
}
catch (Exception ex)
{
MessageBox.Show("Can not open connection ! ");
}
Lexique:
Lexique:
Data Source : Sql server address,attention if it concerns an instance "SQL EXPRESS" -> please add ..myadress..\SQLEXPRESS
数据源:Sql server地址,注意是否涉及实例“SQL EXPRESS” - >请添加..myadress .. \ SQLEXPRESS
Initial Catalog: DataBase name from your sql server
初始目录:来自sql server的DataBase名称
UserId: User account created on sql server to access the database defined
UserId:在sql server上创建的用户帐户,用于访问定义的数据库
Password: it's password ^^
密码:密码是^^
#1
1
The period (.) indicated sql server is running on the same box as the asp.net application.
句点(。)表示sql server与asp.net应用程序在同一个盒子上运行。
My hunch is the connection string you posted was pulled out of a c# string literal. The \\ is really just a single slash, but you need to escape it in C# and the escape character is another \.
我的预感是您发布的连接字符串是从c#字符串文字中提取出来的。 \\实际上只是一个斜杠,但你需要在C#中转义它,转义字符是另一个\。
The sql2008 is the INSTANCE NAME. Sql server can be installed multiple times on a host. The default instance, of which there can be only one, can be reference without the \InstanceName suffix. You can have multiple NAMED INSTANCES. Using the named instance suffix in the connection string is how you designate which instance you are connecting to.
sql2008是INSTANCE NAME。 Sql server可以在主机上多次安装。默认实例(只能有一个)可以在没有\ InstanceName后缀的情况下引用。您可以拥有多个NAMED INSTANCES。在连接字符串中使用命名实例后缀是指定要连接到哪个实例的方式。
EDIT: If "datasource=sql2008" works then perhaps your server name is sql2008 and your database is installed as the default instance. You can determine if you are using a named instance by inspecting the services control panel applet. If you are using a named instance, the sql service will be listed as "SQL SERVER (MSSQLSERVER$INSTANCENAME)".
编辑:如果“datasource = sql2008”工作,那么您的服务器名称可能是sql2008,并且您的数据库是作为默认实例安装的。您可以通过检查服务控制面板小程序来确定您是否正在使用命名实例。如果您使用的是命名实例,则sql服务将列为“SQL SERVER(MSSQLSERVER $ INSTANCENAME)”。
#2
0
This refers to a local instance of sql server running upon the machine that the application is deployed upon. sql2008 is the name of the sql server that is being connected to.
这是指在部署应用程序的机器上运行的sql server的本地实例。 sql2008是要连接的sql server的名称。
#3
0
Hello I use this so if this will help you:
你好我使用这个,如果这对你有帮助:
Data Source= server_name; Initial Catalog=database_name; User ID=user_id;Password=password
or try to do so:
或尝试这样做:
Server=.\server_name;Database=database_name; User ID=user_id;Password=password
#4
0
The ". \" always means from the current position in local
“。\”总是意味着从当地的当前位置
In .NET you can escape special characters by either putting an @ in front of the string or using a special value to represent the character you want to escape. In this case you can use \ to represent a \
在.NET中,您可以通过在字符串前面放置@或使用特殊值来表示要转义的字符来转义特殊字符。在这种情况下,您可以使用\来表示\
".\\" == @".\"
“。\\”== @“。\”
So for me
所以对我来说
"Data Source=.\\SQLServer2005" equal @"Data Source=.\SQLServer2005"
“数据源=。\\ SQLServer2005”等于@“数据源=。\ SQLServer2005”
but
但
"Data Source =.\\SQLServer2005" or "Data Source =.\\\SQLServer2005"
“数据源=。\\ SQLServer2005”或“数据源=。\\\ SQLServer2005”
I do not see what that could mean ...
我不明白这意味着什么......
Do you can try this ?
你能尝试一下吗?
SqlConnection cnn ;
String connetionString = "Data Source=ServerName;Initial Catalog=DatabaseName;User ID=UserName;Password=Password"
cnn = new SqlConnection(connetionString);
try
{
cnn.Open();
MessageBox.Show ("Connection Open ! ");
cnn.Close();
}
catch (Exception ex)
{
MessageBox.Show("Can not open connection ! ");
}
Lexique:
Lexique:
Data Source : Sql server address,attention if it concerns an instance "SQL EXPRESS" -> please add ..myadress..\SQLEXPRESS
数据源:Sql server地址,注意是否涉及实例“SQL EXPRESS” - >请添加..myadress .. \ SQLEXPRESS
Initial Catalog: DataBase name from your sql server
初始目录:来自sql server的DataBase名称
UserId: User account created on sql server to access the database defined
UserId:在sql server上创建的用户帐户,用于访问定义的数据库
Password: it's password ^^
密码:密码是^^