I'm trying to put together an app where I'm first using SQLDMO to get a list of available SQL Servers on a network, then trying to use it to connect to a chosen server and retrieve a list of the available DBs.
I'm completely new to C#, and my knowledge of SQL Server is beginner/intermediate level, so the code I do have is taken from an existing tutorial. However, while I'm able to locate the server on the (non-existent) network, I'm unable to connect to the SQL Server to get a list of the available DBs.
I'm currently trying to get this working on a single machine with a named instance of SQL Server, but I'm just not able to create a connection to the server. SQL Server is set to use Windows Authentication, and my user account is set up in SQL Server as a trusted account. However, the app returns an error message of:
[Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'foo'.
The code in question looks like this:
---------------------------------------
SQLDMO.SQLServer srv = new SQLDMO.SQLServerClass();
srv.Connect(this.cmbServer.SelectedItem.ToString(),this.txtUser.Text,this.txtPassword.Text);
---------------------------------------
cmbServer.SelectedItem does contain the named instance of SQL Server 'FOO\BAR'
I have also tried not passing the username and password, as I thought I had a trusted connection, but obviously this is not the case. Can anyone point me in the right direction?
Loading

Answers
Know the answer? Post it. Somebody with the same question will find it here.