private void Page_Load(object sender, System.EventArgs e) { if (IsPostBack) { Page.Validate(); lblConnectError.Text = ""; if (Page.IsValid) { try { SqlConnection myConnection = new SqlConnection(); myConnection.ConnectionString = "server=" + txtDataSource.Text + ";database=" + txtDatabase.Text + ";uid=" + txtUserID.Text + ";pwd=" + txtPassword.Text + ((txtTimeout.Text.Length > 0) ? ";Connection Timeout=" + txtTimeout.Text : ""); SqlDataAdapter myCommand = new SqlDataAdapter("select * from Account", myConnection); // Can we get to the database? DataSet ds = new DataSet(); myCommand.Fill(ds, "Account"); UpdateConfigWeb(txtDatabase.Text, txtDataSource.Text, txtUserID.Text, txtPassword.Text, txtTimeout.Text, txtSMTP.Text); Response.Redirect("setup3.aspx"); return; } catch (Exception err) { lblConnectError.Text = err.Message; } } lblErrorHeader.Text = "Sorry, cannot connect to your database the following errors occured:"; } else { AppEnv appEnv = new AppEnv(Context); txtDatabase.Text = appEnv.GetAppSetting("database"); if (txtDatabase.Text.Length <= 0) { txtDatabase.Text = "CMSNET"; } txtDataSource.Text = appEnv.GetAppSetting("datasource"); txtUserID.Text = appEnv.GetAppSetting("userid"); txtPassword.Text = appEnv.GetAppSetting("password"); txtTimeout.Text = appEnv.GetAppSetting("timeout"); txtSMTP.Text = appEnv.GetAppSetting("smtpserver"); } }