[英]What setting has to be done to connect with database with this connection string given below?
In my .exe setup having connection string 在我的.exe设置中有连接字符串
Data Source=SERVER;Initial Catalog=POS_Chimur;User ID=sa;Integrated security=false
I have to install database for this exe what settings will be needed according to above connectionString. 我必须为此exe安装数据库,根据上面的connectionString将需要什么设置。
Till now I have installed sql server with default instance with name of pc SERVER . 到目前为止,我已经安装了sql server,其默认实例名称为pc SERVER 。 Still i am unable to connect with above connection string.
仍然我无法连接上面的连接字符串。
You need to cheat your way in. Here's how I would approach this problem: 你需要欺骗自己的方式。以下是我将如何解决这个问题:
Data Source=SERVER;
You can create an alias to point to your final instance using "SQL Server Configuration Manager", "Aliases" 您可以使用“SQL Server配置管理器”,“别名”创建别名以指向最终实例
Initial Catalog=POS_Chimur;
You need to have a database named POS_Chimur 您需要一个名为POS_Chimur的数据库
User ID=sa;Integrated security=false
Here, you need to provide a SQL login named sa with no password. 在这里,您需要提供一个名为sa且没有密码的SQL登录名。 I recommend to rename actual sa account to original_sa then create a new account named sa with no password.
我建议将实际的sa帐户重命名为original_sa,然后创建一个名为sa且没有密码的新帐户。 You also need to create a user mapping for that new account in the POS_Chimur database using this code.
您还需要使用此代码在POS_Chimur数据库中为该新帐户创建用户映射。
CREATE USER sa FOR LOGIN sa;
ALTER ROLE [db_owner] ADD MEMBER sa;
If DBO doesn't work then you can give it SysAdmin rights if you still have error. 如果DBO不起作用,那么如果仍有错误,可以给它SysAdmin权限。
If you are using SQL Server security, you need to specify a username and a password, like this (where you replace 'mySApassword' with the actual password): 如果您使用的是SQL Server安全性,则需要指定用户名和密码,如下所示(将mySApassword替换为实际密码):
Server=SERVER;Database=POS_Chimur;User Id=sa;Password=mySApassword;
In the event you want to use Windows security, you will need this connection string: 如果您要使用Windows安全性,则需要此连接字符串:
Server=SERVER;Database=POS_Chimur;Trusted_Connection=True;
If you are running the executable on the same machine as where SQL Server is running, you can replace 'SERVER' with '.' 如果您在运行SQL Server的同一台计算机上运行可执行文件,则可以将“SERVER”替换为“。” in order to make it work on all computers, if you need to distribute it to more than one pc.
为了使它适用于所有计算机,如果您需要将其分发到多台PC。
Here's some more information about SQL Server 2008 connection strings. 以下是有关SQL Server 2008连接字符串的更多信息。
You need to mention the Provider. 您需要提及提供商。 Your connectionstring should look like this.
您的connectionstring应如下所示。
Data Source=SERVER;Initial Catalog=POS_Chimur;User ID=sa;Integrated security=false; 数据源= SERVER;初始目录= POS_Chimur;用户ID = sa;集成安全性=假; Provider="System.Data.SqlClient"
供应商= “System.Data.SqlClient的”
I see two things mainly: 我主要看两件事:
You are connecting with SQL Server login 您正在连接SQL Server登录
This account is sa and doesn't have a password 此帐户是sa ,没有密码
After performing those steps, please log out, and try to log in again, but change the Authentication drop down value to 'SQL Server Authentication' and try to login with sa and empty password, if it works, then the connection string should be fine too. 执行这些步骤后,请注销,然后尝试再次登录,但将身份验证下拉值更改为“SQL Server身份验证”并尝试使用sa和空密码登录,如果有效,则连接字符串应该没问题太。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.