Accessing Remote SQL 2000 with a proxy account

From: Marina Gofman (marinagofman@hotmail.com)
Date: 06/28/02


From: "Marina Gofman" <marinagofman@hotmail.com>
Date: Thu, 27 Jun 2002 15:52:37 -0700


Hello,
I am just starting with .NET and here is my problem:
I have Windows 2000 (IIS 5) and .NET app on one box.
I am trying to run a simple select query on a remote SQL 2000 server with
Windows security.

So far I cannot connect and get the error: Login failed for user
'domain\username' - (I am using a proxy account)

Any suggestions on how to resolve it would be greatly appreciated.

I changed <processModel > in machine.config : userName=system.
I also changed web.config to include the impersonation tag with the userID
and a password that have reading rights in the DB
(checked it out with the different app)

Another thing that I reset was the security on the app in IS manager to
integrated in order to debug.

Here are the related code snippets:

private void Button1_Click(object sender, System.EventArgs e)

{

SqlConnection myConnection = new
SqlConnection("server=abc;database=mmm;Trusted_Connection=yes");

SqlDataAdapter myCommand = new SqlDataAdapter("select * from tLocation_Dim",
myConnection);

DataSet ds = new DataSet();

myCommand.Fill(ds);

DataGrid1.DataSource = ds.Tables[0].DefaultView;

DataGrid1.DataBind();

}

private void Button2_Click(object sender, System.EventArgs e)

{

SqlConnection oConnection = null;

System.String gsConnectionString;

gsConnectionString = "server=abc;database=mmm;Trusted_Connection=yes";

oConnection = new SqlConnection(gsConnectionString);

oConnection.Open();

System.String sSQL;

sSQL = "select * from tLocation_Dim";

SqlCommand oCommand = new SqlCommand(sSQL, oConnection);

oCommand.CommandType = CommandType.Text;

SqlDataAdapter oDa = new SqlDataAdapter();

DataSet oDs = new DataSet();

oDa.SelectCommand = oCommand;

try

{

oDa.Fill(oDs, "DataSet");

}

catch (Exception ee)

{

throw new Exception("An exception occured in Button2_click", ee);

}

finally

{

// Update Output Parameters

}

}