Windows Services and SQL Server

G

Guest

Greetings everyone,

I am trying to access my SQL Server 2005 database with a windows service,
the problem is that I can't access it!

It says ERROR [28000] [Microsoft][ODBC SQL Server Driver][SQL Server]Login
failed for user 'ONEWORLD\N5DALVES$'.

ONEWORLD is my domain, N5DALVES is my computer name.... the $ appears there
like magic...

in the SQL Server I don't have that user... I have ONEWORLD\DALVES...
that's my username in the intranet...

How can I avoid this? I tried to use this connection string:

DSN=MyDataSource;Uid=TimeFiveUser;Pwd=_TimeFiveUser_;

I'm using ODBC Drivers
 
G

Guest

If you are using managed code, is there any reason why you can't use the
SqlClient class with a regular SQL Server login? e.g.,
server=myserver;database=dbname;uid=user;pwd=password;
--Peter
 
G

Guest

yes there is a reason...

Where planning in the future use more than one database type... maybe oracle
and/or mysql

Since there is that option in the future we prefer to use odbc

Peter Bromberg said:
If you are using managed code, is there any reason why you can't use the
SqlClient class with a regular SQL Server login? e.g.,
server=myserver;database=dbname;uid=user;pwd=password;
--Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net




Diogo Alves said:
Greetings everyone,

I am trying to access my SQL Server 2005 database with a windows service,
the problem is that I can't access it!

It says ERROR [28000] [Microsoft][ODBC SQL Server Driver][SQL Server]Login
failed for user 'ONEWORLD\N5DALVES$'.

ONEWORLD is my domain, N5DALVES is my computer name.... the $ appears there
like magic...

in the SQL Server I don't have that user... I have ONEWORLD\DALVES...
that's my username in the intranet...

How can I avoid this? I tried to use this connection string:

DSN=MyDataSource;Uid=TimeFiveUser;Pwd=_TimeFiveUser_;

I'm using ODBC Drivers
 
G

Guest

There are managed providers for Oracle, MySQL and other RDBMS's. If you use
the Enterprise Library Data Access Block, these only need to be specified in
the configuration file. Your code does not have to change.
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net




Diogo Alves said:
yes there is a reason...

Where planning in the future use more than one database type... maybe oracle
and/or mysql

Since there is that option in the future we prefer to use odbc

Peter Bromberg said:
If you are using managed code, is there any reason why you can't use the
SqlClient class with a regular SQL Server login? e.g.,
server=myserver;database=dbname;uid=user;pwd=password;
--Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net




Diogo Alves said:
Greetings everyone,

I am trying to access my SQL Server 2005 database with a windows service,
the problem is that I can't access it!

It says ERROR [28000] [Microsoft][ODBC SQL Server Driver][SQL Server]Login
failed for user 'ONEWORLD\N5DALVES$'.

ONEWORLD is my domain, N5DALVES is my computer name.... the $ appears there
like magic...

in the SQL Server I don't have that user... I have ONEWORLD\DALVES...
that's my username in the intranet...

How can I avoid this? I tried to use this connection string:

DSN=MyDataSource;Uid=TimeFiveUser;Pwd=_TimeFiveUser_;

I'm using ODBC Drivers
 
A

Andy

yes there is a reason...

Where planning in the future use more than one database type... maybe oracle
and/or mysql

Since there is that option in the future we prefer to use odbc

:


If you are using managed code, is there any reason why you can't use the
SqlClient class with a regular SQL Server login? e.g.,
server=myserver;database=dbname;uid=user;pwd=password;
--Peter
Greetings everyone,
I am trying to access my SQL Server 2005 database with a windows service,
the problem is that I can't access it!
It says ERROR [28000] [Microsoft][ODBC SQL Server Driver][SQL Server]Login
failed for user 'ONEWORLD\N5DALVES$'.
ONEWORLD is my domain, N5DALVES is my computer name.... the $ appears there
like magic...
in the SQL Server I don't have that user... I have ONEWORLD\DALVES...
that's my username in the intranet...
How can I avoid this? I tried to use this connection string:
DSN=MyDataSource;Uid=TimeFiveUser;Pwd=_TimeFiveUser_;
I'm using ODBC Drivers- Hide quoted text -

- Show quoted text -

To answer your question, it looks like you need to add the oneworld
\n5dalves$, because you're running the service as local system (or
local service) which will use the machine login. Your other option is
to run the service under a differnt user account which does have
permission to the sql server.
 
W

Willy Denoyette [MVP]

Diogo Alves said:
Greetings everyone,

I am trying to access my SQL Server 2005 database with a windows service,
the problem is that I can't access it!

It says ERROR [28000] [Microsoft][ODBC SQL Server Driver][SQL Server]Login
failed for user 'ONEWORLD\N5DALVES$'.
Windows services that run in the "Local Service" or "Network Service"
account, authenticate using the machine account with a $ appended on the
network.
ONEWORLD is my domain, N5DALVES is my computer name.... the $ appears
there
like magic...

in the SQL Server I don't have that user... I have ONEWORLD\DALVES...
that's my username in the intranet...

How can I avoid this? I tried to use this connection string:

1. By running your service in a domain account, or
2. When running in a W2K AD domain, you can grant the machine account
(domain\machinename) access rights to the SQL Server database.
DSN=MyDataSource;Uid=TimeFiveUser;Pwd=_TimeFiveUser_;

I'm using ODBC Drivers

Why using legacy ODBC drivers when there are managed stacks available for
most DB's systems on the market?


Willy.
 
S

sloan

Windows Services usually run under the

MachineName\System account. Where MachineName is your own machine name.

Thus your techincial issue.

...

Non techinical, the others are right. You should use ODBC ~only as a last
resort to talk to databases.

If you find EnterpriseLibrary (.Data) you will find a much much better
thought out solution to talking to different dbs.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top