I have a baffling connection problem from my C# console app to a sql
server express database.
The console application opens the sql database using the following
code:-
vDataSource = "server = " + vgSqlServer + "; " +
"database = " + vgSqlServerDb + ";" +
"uid = XXX; pwd = XXX; ";
//create the connection
vSqlConnection = new SqlConnection(vDataSource);
try
{
vSqlConnection.Open();
}
catch (SqlException vSqlEx)
{
//connection failed
Console.Write("Connection Failed.\n\nError Number: " +
vSqlEx.Number + "\n\n" + vSqlEx.Message,
"Database Connection Failed");
}
catch (InvalidOperationException vEx)
{
Console.Write("Invalid Operation.\n\nError Number: " +
"\n\n" + vEx.Message,
"Database Connection Failed");
}
I have placed the application on a network drive ( just copying it not
using publisher) and from my PC the application works fine. However
when I try to run the application from any other machine on the same
network the connection fails with an MS "Tell us about this problem
message" - not even the catch seems to work. On looking at this
message the problem is an unhandled exception because the sqlclient
code cannot get permission to the database.
Both machines are using the same exe, and have similar set-ups.
Windows applications written in C# and accessing the same database
work perfectly on both machines.
I have tried connection using both SQl Server Login id's and windows
authentication with no effect
My machine has both SqlServer express manager and VS so my question
is - does anybody know of a reason why a console application will not
work on a PC where a windows application works correctly?
Sorry this is so long but I have tried to include all the details -
please ask if you need any further info.
Thanks you for your time....
DC
The Wine Society