Problem while reading Text File for DB connection.

Aug 21 2007 3:27 AM
Hi,

I am new to this forum, i am facing a problem related to reading a text file. I have a text file in my application bin directory and i am saving connection string parameters in that so that when the application runs it first read the parameter values from that file and then open the connection and if the parameter values are not correct it prompts the user a window where it can see the previous values and edit them if they are wrong. Here is the code for this procedure:

private void frmDatabaseConnection_Load(object sender, EventArgs e)
        {


           
            if (File.Exists(Environment.CurrentDirectory + @"\DbConnection.txt"))
            {
                string ConnectionStatus;
    TextReader ReadDbConnectionInfo=new StreamReader(          Environment.CurrentDirectory + @"\DbConnection.txt");
                SqlHelper.ServerName=ReadDbConnectionInfo.ReadLine();
                SqlHelper.DatabaseName =ReadDbConnectionInfo.ReadLine ();
                SqlHelper.UserID=ReadDbConnectionInfo.ReadLine();
                SqlHelper.UserPassword=ReadDbConnectionInfo.ReadLine();
                ReadDbConnectionInfo.Close();
                SqlHelper.MakeConnectionstring();
                ConnectionStatus = SqlHelper.IsConnectionValid();
                if (ConnectionStatus == "true")
                {
                   
                    changeActiveWorkspace(objServerMesseges);
                    objServerMesseges.SetServerMessage = "Database connection is valid.............!";
                    ServerOperations(objServerMesseges);
                    nfyIconServer.Text = "Server is running";
                    tmrminimizeserver.Enabled = true;
                }
                else
 {objSetConnectionString.onMinimize+=new usConnectionStringInfo.Minimize(objSetConnectionString_onMinimize);
                    changeActiveWorkspace(objSetConnectionString);
                    objSetConnectionString.SetServerName = SqlHelper.ServerName;
                    objSetConnectionString.SetDatabaseName = SqlHelper.DatabaseName;
                    objSetConnectionString.SetUserName = SqlHelper.UserID;
                    objSetConnectionString.SetUserPassword = SqlHelper.UserPassword;
                    objSetConnectionString.SetServerMessage = "Either SQL Server is not responding or the information provided is not valid"; 
                }
            }
            else
            {
               
                objSetConnectionString.onMinimize +=new usConnectionStringInfo.Minimize(objSetConnectionString_onMinimize);
                changeActiveWorkspace(objSetConnectionString);
            }
           
        }

this code works fine when i run my application from my VS environment even it works fine when i deployed the application but the problem is that it does't work on the start up of the windows i.e my application is added to the start up and even if the parameter values are correct it does't connect to the database. i dont know what is wrong with this code. One thing important that my application setup does't add the exe to start up i manually add it there because i dont know how to add this functionality in my set up project it will be good if some one tell me the solution for this also.

Please help me .
Thanks in advance.