Wednesday, March 28, 2012

Problem with SQL Server 2005 Express Edition

Ok, I've read almost a million ng postings on this, still I can't solve it.
This place is my final hope.
I'll start from the beginning: I have a Windows application developed in C#.
It uses a SQL Server 2005 Express Edition database to store data. Now I have
created a deployment of this app and database, and I try to install it on my
own machine. No problems, works without errors.
Now, I put this deployment project on the network and a user downloads it to
his Vista machine and runs the setup. When he starts the app he gets the
following error message:
"Login failed for user "MyUser". The user is not associated with a thrusted
server connection".
The connection string I use in my application is this:
Server=.\SQLEXPRESS;Database=MyDB;User ID=MyUser;Password=thissucks
Since I have no control over the Vista machine, I can't force him/her to
create a new account that is thrusted. All I want is to deploy my app and
database, without having to worry about authorization and stuff. If
possible, it should allow for ALL users to connect and use it.
I have already tried alot of the suggestions I've found, but lets start all
over so it will be right. What should I do to remove this error? How can I
deploy my database without having to think about authorization/security
stuff?
TIA
PZPreben,
You deployed your database and your code, correct? A SQL Server login is
not in the database, but is stored in the master database. Does your
deployment include the step to create the SQL Server login "MyUser"?
If not, then you will need to supply a script to do that. Such as (from the
BOL):
CREATE LOGIN MyUser WITH PASSWORD = '3KHJ6dhx(0xVYsdf'
Another possibility is that you have created the login, but the client's SQL
Server 2005 Express installation was set with Authentication Mode = Windows
Authentication Mode. If so, that installation is not willing to accept a
SQL Login and will need to be changed to Mixed Mode.
RLF
"Preben Zacho" <post@.zacho-web.dk> wrote in message
news:OKXT6f4lHHA.1776@.TK2MSFTNGP05.phx.gbl...
> Ok, I've read almost a million ng postings on this, still I can't solve
> it. This place is my final hope.
> I'll start from the beginning: I have a Windows application developed in
> C#. It uses a SQL Server 2005 Express Edition database to store data. Now
> I have created a deployment of this app and database, and I try to install
> it on my own machine. No problems, works without errors.
> Now, I put this deployment project on the network and a user downloads it
> to his Vista machine and runs the setup. When he starts the app he gets
> the following error message:
> "Login failed for user "MyUser". The user is not associated with a
> thrusted
> server connection".
> The connection string I use in my application is this:
> Server=.\SQLEXPRESS;Database=MyDB;User ID=MyUser;Password=thissucks
> Since I have no control over the Vista machine, I can't force him/her to
> create a new account that is thrusted. All I want is to deploy my app and
> database, without having to worry about authorization and stuff. If
> possible, it should allow for ALL users to connect and use it.
> I have already tried alot of the suggestions I've found, but lets start
> all over so it will be right. What should I do to remove this error? How
> can I deploy my database without having to think about
> authorization/security stuff?
> TIA
> PZ
>
>|||Since you are specifying the user name and password in the connection string
I assume you are using SQL Server authentication for your logins rather than
Windows authentication. One cause for that error is trying to use a SQL
Server login on a database server that is configured to only accept Windows
logins.
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"Preben Zacho" <post@.zacho-web.dk> wrote in message
news:OKXT6f4lHHA.1776@.TK2MSFTNGP05.phx.gbl...
> Ok, I've read almost a million ng postings on this, still I can't solve
> it. This place is my final hope.
> I'll start from the beginning: I have a Windows application developed in
> C#. It uses a SQL Server 2005 Express Edition database to store data. Now
> I have created a deployment of this app and database, and I try to install
> it on my own machine. No problems, works without errors.
> Now, I put this deployment project on the network and a user downloads it
> to his Vista machine and runs the setup. When he starts the app he gets
> the following error message:
> "Login failed for user "MyUser". The user is not associated with a
> thrusted
> server connection".
> The connection string I use in my application is this:
> Server=.\SQLEXPRESS;Database=MyDB;User ID=MyUser;Password=thissucks
> Since I have no control over the Vista machine, I can't force him/her to
> create a new account that is thrusted. All I want is to deploy my app and
> database, without having to worry about authorization and stuff. If
> possible, it should allow for ALL users to connect and use it.
> I have already tried alot of the suggestions I've found, but lets start
> all over so it will be right. What should I do to remove this error? How
> can I deploy my database without having to think about
> authorization/security stuff?
> TIA
> PZ
>
>|||Hi Russell

> If not, then you will need to supply a script to do that. Such as (from
> the BOL):
> CREATE LOGIN MyUser WITH PASSWORD = '3KHJ6dhx(0xVYsdf'
I think so. I have 2 scripts that comes with the deployment: The first one
creates the user MyUser in the server scope. The next one creates the
database itself (thats what I mean with "deploying" the database). Both
scripts run in sqlcmd without errors. I then check to see if I can run a SQL
statements by doing this:
sqlcmd -S .\SQLEXPRESS
1> select * from customer
2> go
The SQL statement is then executed without any problems, so the database
seems to have been created alright.

>Another possibility is that you have created the login, but the client's
>SQL Server 2005 Express installation was set with Authentication Mode =
>Windows Authentication Mode. If so, that installation is not willing to
>accept a SQL Login and will need to be changed to Mixed Mode.
How do I check this on the remote machine? Can I somehow change this using a
script?
/PZ
"Russell Fields" <russellfields@.nomail.com> wrote in message
news:%23%230xS27lHHA.4868@.TK2MSFTNGP06.phx.gbl...
> Preben,
> You deployed your database and your code, correct? A SQL Server login is
> not in the database, but is stored in the master database. Does your
> deployment include the step to create the SQL Server login "MyUser"?
> If not, then you will need to supply a script to do that. Such as (from
> the BOL):
> CREATE LOGIN MyUser WITH PASSWORD = '3KHJ6dhx(0xVYsdf'
> Another possibility is that you have created the login, but the client's
> SQL Server 2005 Express installation was set with Authentication Mode =
> Windows Authentication Mode. If so, that installation is not willing to
> accept a SQL Login and will need to be changed to Mixed Mode.
> RLF
> "Preben Zacho" <post@.zacho-web.dk> wrote in message
> news:OKXT6f4lHHA.1776@.TK2MSFTNGP05.phx.gbl...
>|||Hi Roger
How can I determine this? And how do I change it if that is the case?
/PZ
"Roger Wolter[MSFT]" <rwolter@.online.microsoft.com> wrote in message
news:1105D112-C515-42E4-924D-85184144DC2A@.microsoft.com...
> Since you are specifying the user name and password in the connection
> string I assume you are using SQL Server authentication for your logins
> rather than Windows authentication. One cause for that error is trying to
> use a SQL Server login on a database server that is configured to only
> accept Windows logins.
> --
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
> Use of included script samples are subject to the terms specified at
> http://www.microsoft.com/info/cpyright.htm
> "Preben Zacho" <post@.zacho-web.dk> wrote in message
> news:OKXT6f4lHHA.1776@.TK2MSFTNGP05.phx.gbl...
>|||Here are the instructions for changing it.
http://msdn2.microsoft.com/en-us/library/ms188670.aspx
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"Preben Zacho" <post@.zacho-web.dk> wrote in message
news:%23F%23hPh$lHHA.4568@.TK2MSFTNGP02.phx.gbl...
> Hi Roger
> How can I determine this? And how do I change it if that is the case?
> /PZ
> "Roger Wolter[MSFT]" <rwolter@.online.microsoft.com> wrote in message
> news:1105D112-C515-42E4-924D-85184144DC2A@.microsoft.com...
>|||Hi Roger
This is a prerequisit deployment, which means the SQL Server 2005 Express
Edition is downloaded and installed automatically during setup and before
tha application is installed. As far as I know, the SQL Server Management
Studio is not by default part of this installation (at least I can't find
it). And I don't want my users to download additional software to get this
working.
The strange thing is this: I can execute a select statement using the SQLCMD
tool without any problems. And from the Visual Studio 2005 I can go to the
Server Tools and connect to the database as well and query tables there,
also without errors. But my application come up with the "Login failed for
user "MyUser". The user is not associated with a thrusted server connection"
message all the time. I was wondering if my connection string should be
turned to Windows authentication instead, which it seems both SQLCMD and
Visual Studio is using (cause I don't have to login when doing that).
/PZ
"Roger Wolter[MSFT]" <rwolter@.online.microsoft.com> wrote in message
news:06C7E2FB-B373-4066-972B-EC2FB00D292E@.microsoft.com...
> Here are the instructions for changing it.
> http://msdn2.microsoft.com/en-us/library/ms188670.aspx
>
> --
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
> Use of included script samples are subject to the terms specified at
> http://www.microsoft.com/info/cpyright.htm
> "Preben Zacho" <post@.zacho-web.dk> wrote in message
> news:%23F%23hPh$lHHA.4568@.TK2MSFTNGP02.phx.gbl...
>|||Ok, so I got it to work now. I simply changed from SQL Authentication to
Windows Authentication and changed my connection string. Seems that the
deployment goes smoothly after all, since when installating the SQL Server
2005 as prerequisit, the installing user is created as a login user. I was
not awear of that.
The database itself is then created using a script call to SQLCMD and the
application can run without errors.
I can live with that, it makes the installation quite simple after all.
/PZ
"Preben Zacho" <post@.zacho-web.dk> wrote in message
news:OKXT6f4lHHA.1776@.TK2MSFTNGP05.phx.gbl...
> Ok, I've read almost a million ng postings on this, still I can't solve
> it. This place is my final hope.
> I'll start from the beginning: I have a Windows application developed in
> C#. It uses a SQL Server 2005 Express Edition database to store data. Now
> I have created a deployment of this app and database, and I try to install
> it on my own machine. No problems, works without errors.
> Now, I put this deployment project on the network and a user downloads it
> to his Vista machine and runs the setup. When he starts the app he gets
> the following error message:
> "Login failed for user "MyUser". The user is not associated with a
> thrusted
> server connection".
> The connection string I use in my application is this:
> Server=.\SQLEXPRESS;Database=MyDB;User ID=MyUser;Password=thissucks
> Since I have no control over the Vista machine, I can't force him/her to
> create a new account that is thrusted. All I want is to deploy my app and
> database, without having to worry about authorization and stuff. If
> possible, it should allow for ALL users to connect and use it.
> I have already tried alot of the suggestions I've found, but lets start
> all over so it will be right. What should I do to remove this error? How
> can I deploy my database without having to think about
> authorization/security stuff?
> TIA
> PZ
>
>

No comments:

Post a Comment