Saturday, February 25, 2012

connection string using sql authentication

i'm having trouble getting my project to work on other machines using windows authentication, so as this is urgent I want to change it to sql authentication. I've enabled sql authentication and enabled the sa login, could someone please tell me how to connect to my db

my connection string is currently as follows using windows authentication:

<

connectionStrings>

<

addname="GuitarShackConnection"connectionString="Server=(local)\SqlExpress;Integrated Security=True;Database=GuitarShack;"providerName="System.Data.SqlClient"/>

<

addname="GuitarShackConnectionString"connectionString="Data Source=(local)\SQLEXPRESS;Initial Catalog=GuitarShack;Integrated Security=True"providerName="System.Data.SqlClient"/>

<

addname="CustomerNameDS"connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True"providerName="System.Data.SqlClient"/>

</

connectionStrings><add name="ConnectionString" connectionString="Server=.\SQLEXPRESS;Database=xxxxxxxxxx;User ID=xxxxxxx;Password=xxxxxxx;Trusted_Connection=False"
providerName="System.Data.SqlClient" />|||

i've enabled sa and restarted the sql service but when i go to modify the connection in the database explorer and enter the credentials it returns an error when i test the connection:

the user sa is not associated with a trusted sql connection

any ideas what would cause this?

|||The full ins and outs of Sql Server permissions are beyond me, because I find it difficult to remember what user can do what. So I administer my servers using Windows Authentication on the local machine, set the Server up to operate in Mixed Mode, then create application users. I give these users the absolute minimum permissions possible, which is only actuallyExecute on the stored procedures I create for the app. They have no SELECT, DELETE, UPDATE or INSERT permissions. I know that you must NEVER use the sa account to connect to SQL Server from your ASP.NET app. That user has every privilege going.|||

Hi, the follow steps may be helpful to you.

To change security authentication mode
1. In SQL Server Management Studio Object Explorer, right-click your server, and then click Properties.
2. On the Security page, under Server authentication, select the new server authentication mode, and then click OK.
3. In the SQL Server Management Studio dialog box, click OK, to acknowledge the need to restart SQL Server.


To restart SQL Server from SQL Server Management Studio
1. In Object Explorer, right-click your server, and then click Restart. If running, SQL Server Agent must also be restarted.


To enable the sa login
1. Execute the following statements to enable the sa password and assign a password.
ALTER LOGIN sa ENABLE ;
GO
ALTER LOGIN sa WITH PASSWORD = '<password>' ;
GO

Thanks.

No comments:

Post a Comment