I see from your code that you are using SQL Server's integrated security. It
means that SQL Server uses the account under which the application is
running, and not the user ID and password quoted in the connection string,
to decide whether it will let it in or not.
ASP.NET applications run under a local machine account named ASPNET. You
need to give this account the necessary rights. If your database were
located on the same computer as the executable then I'd advise you to make
the account a member of the Administrators" group. But since your database
is located on a remote computer, I'm not sure what would be the best thing
to do. Maybe impersonation?
Viele Grüße nach Leipzig,
Michal
--
Michal Boleslav Mechura
"Frank Schumacher" <> wrote in message
news:%...
> Hi NG,
>
> I try to connect to a remote MS-SQL-Server 2000 from an ASP.NET
> application. Here's how I do it:
>
> private void ConnectToDatabase(string host, string dataBaseName, string
> userID, string password)
> {
> string connectionString;
>
> connectionString = "Initial Catalog=" + dataBaseName + ";";
> connectionString += "Data Source=" + host + ";";
> connectionString += "Integrated Security=SSPI;";
> connectionString += "User ID=" + userID + ";";
> connectionString += "Password=" + password + ";";
>
> _myConnection = new SqlConnection();
> _myConnection.ConnectionString = connectionString;
> try
> {
> _myConnection.Open();
> }
> catch (Exception e)
> {
> throw e;
> }
> }
>
> If I use this module in a windows-gui c# project, it works fine. But in an
> ASP.NET application I get the error: Login failed for user
> 'domainname\computername$'
> I have double checked User ID and Password in the connetion string, but
> they were correct.
>
> Any ideas on that?
>
> Thanks,
> Frank