Need help builing connection string to database.

G

Guest

I am having problems getting the connection string to return a value. It
keeps coming up null. What am I doing wrong?

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Configuration;
using StaticMembers = FMRSystemsUtility.StaticMembers;
using System.Xml;

namespace FMRSystems
{
/// <summary>
/// Summary description for frmSplash.
/// </summary>
public class frmSplash : System.Windows.Forms.Form
{
private Infragistics.Win.Misc.UltraButton ubtnLogIn;
private Infragistics.Win.Misc.UltraButton ubtnCancel;
private System.Windows.Forms.ComboBox cbxEnv;
private System.Windows.Forms.TextBox txtUser;
private System.Windows.Forms.TextBox txtPwd;
private System.Windows.Forms.Label lblUserName;
private System.Windows.Forms.Label lblPwd;
private System.Windows.Forms.Label lblEnv;
private System.Windows.Forms.StatusBar sbLogin;
private System.Windows.Forms.PictureBox pictureBox1;
public bool Connected = false;
private System.Windows.Forms.Label label1;
private Infragistics.Win.Misc.UltraButton ubtnChangePwd;
DataServices ds = new DataServices();

/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public frmSplash()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
Infragistics.Win.Appearance appearance1 = new
Infragistics.Win.Appearance();
System.Resources.ResourceManager resources = new
System.Resources.ResourceManager(typeof(frmSplash));
this.ubtnLogIn = new Infragistics.Win.Misc.UltraButton();
this.ubtnCancel = new Infragistics.Win.Misc.UltraButton();
this.cbxEnv = new System.Windows.Forms.ComboBox();
this.txtUser = new System.Windows.Forms.TextBox();
this.txtPwd = new System.Windows.Forms.TextBox();
this.lblUserName = new System.Windows.Forms.Label();
this.lblPwd = new System.Windows.Forms.Label();
this.lblEnv = new System.Windows.Forms.Label();
this.sbLogin = new System.Windows.Forms.StatusBar();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.label1 = new System.Windows.Forms.Label();
this.ubtnChangePwd = new Infragistics.Win.Misc.UltraButton();
this.SuspendLayout();
//
// ubtnLogIn
//
this.ubtnLogIn.ButtonStyle = Infragistics.Win.UIElementButtonStyle.Flat;
this.ubtnLogIn.Font = new System.Drawing.Font("Microsoft Sans Serif",
8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
this.ubtnLogIn.Location = new System.Drawing.Point(152, 176);
this.ubtnLogIn.Name = "ubtnLogIn";
appearance1.BackColor = System.Drawing.Color.LightSteelBlue;
appearance1.BackColor2 = System.Drawing.Color.WhiteSmoke;
appearance1.BackGradientStyle =
Infragistics.Win.GradientStyle.BackwardDiagonal;
this.ubtnLogIn.PressedAppearance = appearance1;
this.ubtnLogIn.TabIndex = 4;
this.ubtnLogIn.Text = "Log In";
this.ubtnLogIn.Click += new System.EventHandler(this.ubtnLogIn_Click);
//
// ubtnCancel
//
this.ubtnCancel.ButtonStyle = Infragistics.Win.UIElementButtonStyle.Flat;
this.ubtnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.ubtnCancel.Font = new System.Drawing.Font("Microsoft Sans Serif",
8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
this.ubtnCancel.Location = new System.Drawing.Point(232, 176);
this.ubtnCancel.Name = "ubtnCancel";
this.ubtnCancel.TabIndex = 5;
this.ubtnCancel.Text = "Cancel";
this.ubtnCancel.Click += new System.EventHandler(this.ubtnCancel_Click);
//
// cbxEnv
//
this.cbxEnv.DropDownStyle =
System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbxEnv.Items.AddRange(new object[] {
"Parallel",
"UserTest",
"Development"});
this.cbxEnv.Location = new System.Drawing.Point(232, 128);
this.cbxEnv.Name = "cbxEnv";
this.cbxEnv.Size = new System.Drawing.Size(144, 21);
this.cbxEnv.TabIndex = 3;
//
// txtUser
//
this.txtUser.Location = new System.Drawing.Point(232, 80);
this.txtUser.Name = "txtUser";
this.txtUser.Size = new System.Drawing.Size(144, 20);
this.txtUser.TabIndex = 1;
this.txtUser.Text = "";
//
// txtPwd
//
this.txtPwd.Location = new System.Drawing.Point(232, 104);
this.txtPwd.Name = "txtPwd";
this.txtPwd.PasswordChar = '*';
this.txtPwd.Size = new System.Drawing.Size(144, 20);
this.txtPwd.TabIndex = 2;
this.txtPwd.Text = "";
//
// lblUserName
//
this.lblUserName.Font = new System.Drawing.Font("Microsoft Sans Serif",
8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
this.lblUserName.ForeColor = System.Drawing.Color.MidnightBlue;
this.lblUserName.Location = new System.Drawing.Point(128, 80);
this.lblUserName.Name = "lblUserName";
this.lblUserName.TabIndex = 0;
this.lblUserName.Text = "User Name:";
this.lblUserName.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// lblPwd
//
this.lblPwd.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
this.lblPwd.ForeColor = System.Drawing.Color.MidnightBlue;
this.lblPwd.Location = new System.Drawing.Point(128, 104);
this.lblPwd.Name = "lblPwd";
this.lblPwd.TabIndex = 0;
this.lblPwd.Text = "Password:";
this.lblPwd.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// lblEnv
//
this.lblEnv.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
this.lblEnv.ForeColor = System.Drawing.Color.MidnightBlue;
this.lblEnv.Location = new System.Drawing.Point(128, 128);
this.lblEnv.Name = "lblEnv";
this.lblEnv.TabIndex = 0;
this.lblEnv.Text = "Database:";
this.lblEnv.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// sbLogin
//
this.sbLogin.Enabled = false;
this.sbLogin.Font = new System.Drawing.Font("Microsoft Sans Serif", 6F,
System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
this.sbLogin.Location = new System.Drawing.Point(0, 216);
this.sbLogin.Name = "sbLogin";
this.sbLogin.Size = new System.Drawing.Size(472, 16);
this.sbLogin.SizingGrip = false;
this.sbLogin.TabIndex = 0;
this.sbLogin.Text = "Ready";
//
// pictureBox1
//
this.pictureBox1.Image =
((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(40, 64);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(64, 104);
this.pictureBox1.TabIndex = 6;
this.pictureBox1.TabStop = false;
//
// label1
//
this.label1.BackColor = System.Drawing.Color.AliceBlue;
this.label1.Dock = System.Windows.Forms.DockStyle.Top;
this.label1.Font = new System.Drawing.Font("Arial", 12F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
this.label1.ForeColor = System.Drawing.Color.MidnightBlue;
this.label1.Location = new System.Drawing.Point(0, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(472, 48);
this.label1.TabIndex = 0;
this.label1.Text = "Film Managment Reporting Systems";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// ubtnChangePwd
//
this.ubtnChangePwd.ButtonStyle =
Infragistics.Win.UIElementButtonStyle.Flat;
this.ubtnChangePwd.Font = new System.Drawing.Font("Microsoft Sans Serif",
8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
this.ubtnChangePwd.Location = new System.Drawing.Point(312, 176);
this.ubtnChangePwd.Name = "ubtnChangePwd";
this.ubtnChangePwd.TabIndex = 7;
this.ubtnChangePwd.Text = "Password";
this.ubtnChangePwd.Click += new
System.EventHandler(this.ubtnChangePwd_Click);
//
// frmSplash
//
this.AcceptButton = this.ubtnLogIn;
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.BackColor = System.Drawing.Color.WhiteSmoke;
this.CancelButton = this.ubtnCancel;
this.ClientSize = new System.Drawing.Size(472, 232);
this.Controls.Add(this.ubtnChangePwd);
this.Controls.Add(this.label1);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.sbLogin);
this.Controls.Add(this.lblEnv);
this.Controls.Add(this.lblPwd);
this.Controls.Add(this.lblUserName);
this.Controls.Add(this.txtPwd);
this.Controls.Add(this.txtUser);
this.Controls.Add(this.cbxEnv);
this.Controls.Add(this.ubtnCancel);
this.Controls.Add(this.ubtnLogIn);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "frmSplash";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Film Management Systems";
this.Load += new System.EventHandler(this.frmSplash_Load);
this.ResumeLayout(false);

}
#endregion

private void ubtnLogIn_Click(object sender, System.EventArgs e)
{

string ConnectionString ="";
frmPassword frmPwd;
DialogResult pwd;


this.sbLogin.Text = "Connecting to the " + this.cbxEnv.Text+ "
Database...";

//get the connectionstring from app.config
AppSettingsReader asr = new AppSettingsReader();
ConfigurationSettings.GetConfig("appSettings");
ConnectionString = ConfigurationSettings.AppSettings.Get(this.cbxEnv.Text);

//(string) asr.GetValue(this.cbxEnv.Text, typeof(string));
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Next time do not post the entire code, it's unnecesary and makes difficult
to find the problem.

AppSettingsReader asr = new AppSettingsReader();
ConfigurationSettings.GetConfig("appSettings");
ConnectionString = ConfigurationSettings.AppSettings.Get(this.cbxEnv.Text);

Do you have different conenction strings ?
try this
ConfigurationSettings.AppSettings[ connName];



OriginalStealth said:
I am having problems getting the connection string to return a value. It
keeps coming up null. What am I doing wrong?

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Configuration;
using StaticMembers = FMRSystemsUtility.StaticMembers;
using System.Xml;

namespace FMRSystems
{
/// <summary>
/// Summary description for frmSplash.
/// </summary>
public class frmSplash : System.Windows.Forms.Form
{
private Infragistics.Win.Misc.UltraButton ubtnLogIn;
private Infragistics.Win.Misc.UltraButton ubtnCancel;
private System.Windows.Forms.ComboBox cbxEnv;
private System.Windows.Forms.TextBox txtUser;
private System.Windows.Forms.TextBox txtPwd;
private System.Windows.Forms.Label lblUserName;
private System.Windows.Forms.Label lblPwd;
private System.Windows.Forms.Label lblEnv;
private System.Windows.Forms.StatusBar sbLogin;
private System.Windows.Forms.PictureBox pictureBox1;
public bool Connected = false;
private System.Windows.Forms.Label label1;
private Infragistics.Win.Misc.UltraButton ubtnChangePwd;
DataServices ds = new DataServices();

/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public frmSplash()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
Infragistics.Win.Appearance appearance1 = new
Infragistics.Win.Appearance();
System.Resources.ResourceManager resources = new
System.Resources.ResourceManager(typeof(frmSplash));
this.ubtnLogIn = new Infragistics.Win.Misc.UltraButton();
this.ubtnCancel = new Infragistics.Win.Misc.UltraButton();
this.cbxEnv = new System.Windows.Forms.ComboBox();
this.txtUser = new System.Windows.Forms.TextBox();
this.txtPwd = new System.Windows.Forms.TextBox();
this.lblUserName = new System.Windows.Forms.Label();
this.lblPwd = new System.Windows.Forms.Label();
this.lblEnv = new System.Windows.Forms.Label();
this.sbLogin = new System.Windows.Forms.StatusBar();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.label1 = new System.Windows.Forms.Label();
this.ubtnChangePwd = new Infragistics.Win.Misc.UltraButton();
this.SuspendLayout();
//
// ubtnLogIn
//
this.ubtnLogIn.ButtonStyle = Infragistics.Win.UIElementButtonStyle.Flat;
this.ubtnLogIn.Font = new System.Drawing.Font("Microsoft Sans Serif",
8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
this.ubtnLogIn.Location = new System.Drawing.Point(152, 176);
this.ubtnLogIn.Name = "ubtnLogIn";
appearance1.BackColor = System.Drawing.Color.LightSteelBlue;
appearance1.BackColor2 = System.Drawing.Color.WhiteSmoke;
appearance1.BackGradientStyle =
Infragistics.Win.GradientStyle.BackwardDiagonal;
this.ubtnLogIn.PressedAppearance = appearance1;
this.ubtnLogIn.TabIndex = 4;
this.ubtnLogIn.Text = "Log In";
this.ubtnLogIn.Click += new System.EventHandler(this.ubtnLogIn_Click);
//
// ubtnCancel
//
this.ubtnCancel.ButtonStyle = Infragistics.Win.UIElementButtonStyle.Flat;
this.ubtnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.ubtnCancel.Font = new System.Drawing.Font("Microsoft Sans Serif",
8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
this.ubtnCancel.Location = new System.Drawing.Point(232, 176);
this.ubtnCancel.Name = "ubtnCancel";
this.ubtnCancel.TabIndex = 5;
this.ubtnCancel.Text = "Cancel";
this.ubtnCancel.Click += new System.EventHandler(this.ubtnCancel_Click);
//
// cbxEnv
//
this.cbxEnv.DropDownStyle =
System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbxEnv.Items.AddRange(new object[] {
"Parallel",
"UserTest",
"Development"});
this.cbxEnv.Location = new System.Drawing.Point(232, 128);
this.cbxEnv.Name = "cbxEnv";
this.cbxEnv.Size = new System.Drawing.Size(144, 21);
this.cbxEnv.TabIndex = 3;
//
// txtUser
//
this.txtUser.Location = new System.Drawing.Point(232, 80);
this.txtUser.Name = "txtUser";
this.txtUser.Size = new System.Drawing.Size(144, 20);
this.txtUser.TabIndex = 1;
this.txtUser.Text = "";
//
// txtPwd
//
this.txtPwd.Location = new System.Drawing.Point(232, 104);
this.txtPwd.Name = "txtPwd";
this.txtPwd.PasswordChar = '*';
this.txtPwd.Size = new System.Drawing.Size(144, 20);
this.txtPwd.TabIndex = 2;
this.txtPwd.Text = "";
//
// lblUserName
//
this.lblUserName.Font = new System.Drawing.Font("Microsoft Sans Serif",
8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
this.lblUserName.ForeColor = System.Drawing.Color.MidnightBlue;
this.lblUserName.Location = new System.Drawing.Point(128, 80);
this.lblUserName.Name = "lblUserName";
this.lblUserName.TabIndex = 0;
this.lblUserName.Text = "User Name:";
this.lblUserName.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// lblPwd
//
this.lblPwd.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
this.lblPwd.ForeColor = System.Drawing.Color.MidnightBlue;
this.lblPwd.Location = new System.Drawing.Point(128, 104);
this.lblPwd.Name = "lblPwd";
this.lblPwd.TabIndex = 0;
this.lblPwd.Text = "Password:";
this.lblPwd.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// lblEnv
//
this.lblEnv.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
this.lblEnv.ForeColor = System.Drawing.Color.MidnightBlue;
this.lblEnv.Location = new System.Drawing.Point(128, 128);
this.lblEnv.Name = "lblEnv";
this.lblEnv.TabIndex = 0;
this.lblEnv.Text = "Database:";
this.lblEnv.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// sbLogin
//
this.sbLogin.Enabled = false;
this.sbLogin.Font = new System.Drawing.Font("Microsoft Sans Serif", 6F,
System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
this.sbLogin.Location = new System.Drawing.Point(0, 216);
this.sbLogin.Name = "sbLogin";
this.sbLogin.Size = new System.Drawing.Size(472, 16);
this.sbLogin.SizingGrip = false;
this.sbLogin.TabIndex = 0;
this.sbLogin.Text = "Ready";
//
// pictureBox1
//
this.pictureBox1.Image =
((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(40, 64);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(64, 104);
this.pictureBox1.TabIndex = 6;
this.pictureBox1.TabStop = false;
//
// label1
//
this.label1.BackColor = System.Drawing.Color.AliceBlue;
this.label1.Dock = System.Windows.Forms.DockStyle.Top;
this.label1.Font = new System.Drawing.Font("Arial", 12F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
this.label1.ForeColor = System.Drawing.Color.MidnightBlue;
this.label1.Location = new System.Drawing.Point(0, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(472, 48);
this.label1.TabIndex = 0;
this.label1.Text = "Film Managment Reporting Systems";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// ubtnChangePwd
//
this.ubtnChangePwd.ButtonStyle =
Infragistics.Win.UIElementButtonStyle.Flat;
this.ubtnChangePwd.Font = new System.Drawing.Font("Microsoft Sans Serif",
8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
this.ubtnChangePwd.Location = new System.Drawing.Point(312, 176);
this.ubtnChangePwd.Name = "ubtnChangePwd";
this.ubtnChangePwd.TabIndex = 7;
this.ubtnChangePwd.Text = "Password";
this.ubtnChangePwd.Click += new
System.EventHandler(this.ubtnChangePwd_Click);
//
// frmSplash
//
this.AcceptButton = this.ubtnLogIn;
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.BackColor = System.Drawing.Color.WhiteSmoke;
this.CancelButton = this.ubtnCancel;
this.ClientSize = new System.Drawing.Size(472, 232);
this.Controls.Add(this.ubtnChangePwd);
this.Controls.Add(this.label1);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.sbLogin);
this.Controls.Add(this.lblEnv);
this.Controls.Add(this.lblPwd);
this.Controls.Add(this.lblUserName);
this.Controls.Add(this.txtPwd);
this.Controls.Add(this.txtUser);
this.Controls.Add(this.cbxEnv);
this.Controls.Add(this.ubtnCancel);
this.Controls.Add(this.ubtnLogIn);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "frmSplash";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Film Management Systems";
this.Load += new System.EventHandler(this.frmSplash_Load);
this.ResumeLayout(false);

}
#endregion

private void ubtnLogIn_Click(object sender, System.EventArgs e)
{

string ConnectionString ="";
frmPassword frmPwd;
DialogResult pwd;


this.sbLogin.Text = "Connecting to the " + this.cbxEnv.Text+ "
Database...";

//get the connectionstring from app.config
AppSettingsReader asr = new AppSettingsReader();
ConfigurationSettings.GetConfig("appSettings");
ConnectionString =
ConfigurationSettings.AppSettings.Get(this.cbxEnv.Text);

//(string) asr.GetValue(this.cbxEnv.Text, typeof(string));
 
C

Cor Ligthert[MVP]

The most given link in these newsgroups

www.connectionstrings.com


OriginalStealth said:
I am having problems getting the connection string to return a value. It
keeps coming up null. What am I doing wrong?

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Configuration;
using StaticMembers = FMRSystemsUtility.StaticMembers;
using System.Xml;

namespace FMRSystems
{
/// <summary>
/// Summary description for frmSplash.
/// </summary>
public class frmSplash : System.Windows.Forms.Form
{
private Infragistics.Win.Misc.UltraButton ubtnLogIn;
private Infragistics.Win.Misc.UltraButton ubtnCancel;
private System.Windows.Forms.ComboBox cbxEnv;
private System.Windows.Forms.TextBox txtUser;
private System.Windows.Forms.TextBox txtPwd;
private System.Windows.Forms.Label lblUserName;
private System.Windows.Forms.Label lblPwd;
private System.Windows.Forms.Label lblEnv;
private System.Windows.Forms.StatusBar sbLogin;
private System.Windows.Forms.PictureBox pictureBox1;
public bool Connected = false;
private System.Windows.Forms.Label label1;
private Infragistics.Win.Misc.UltraButton ubtnChangePwd;
DataServices ds = new DataServices();

/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public frmSplash()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
Infragistics.Win.Appearance appearance1 = new
Infragistics.Win.Appearance();
System.Resources.ResourceManager resources = new
System.Resources.ResourceManager(typeof(frmSplash));
this.ubtnLogIn = new Infragistics.Win.Misc.UltraButton();
this.ubtnCancel = new Infragistics.Win.Misc.UltraButton();
this.cbxEnv = new System.Windows.Forms.ComboBox();
this.txtUser = new System.Windows.Forms.TextBox();
this.txtPwd = new System.Windows.Forms.TextBox();
this.lblUserName = new System.Windows.Forms.Label();
this.lblPwd = new System.Windows.Forms.Label();
this.lblEnv = new System.Windows.Forms.Label();
this.sbLogin = new System.Windows.Forms.StatusBar();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.label1 = new System.Windows.Forms.Label();
this.ubtnChangePwd = new Infragistics.Win.Misc.UltraButton();
this.SuspendLayout();
//
// ubtnLogIn
//
this.ubtnLogIn.ButtonStyle = Infragistics.Win.UIElementButtonStyle.Flat;
this.ubtnLogIn.Font = new System.Drawing.Font("Microsoft Sans Serif",
8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
this.ubtnLogIn.Location = new System.Drawing.Point(152, 176);
this.ubtnLogIn.Name = "ubtnLogIn";
appearance1.BackColor = System.Drawing.Color.LightSteelBlue;
appearance1.BackColor2 = System.Drawing.Color.WhiteSmoke;
appearance1.BackGradientStyle =
Infragistics.Win.GradientStyle.BackwardDiagonal;
this.ubtnLogIn.PressedAppearance = appearance1;
this.ubtnLogIn.TabIndex = 4;
this.ubtnLogIn.Text = "Log In";
this.ubtnLogIn.Click += new System.EventHandler(this.ubtnLogIn_Click);
//
// ubtnCancel
//
this.ubtnCancel.ButtonStyle = Infragistics.Win.UIElementButtonStyle.Flat;
this.ubtnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.ubtnCancel.Font = new System.Drawing.Font("Microsoft Sans Serif",
8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
this.ubtnCancel.Location = new System.Drawing.Point(232, 176);
this.ubtnCancel.Name = "ubtnCancel";
this.ubtnCancel.TabIndex = 5;
this.ubtnCancel.Text = "Cancel";
this.ubtnCancel.Click += new System.EventHandler(this.ubtnCancel_Click);
//
// cbxEnv
//
this.cbxEnv.DropDownStyle =
System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbxEnv.Items.AddRange(new object[] {
"Parallel",
"UserTest",
"Development"});
this.cbxEnv.Location = new System.Drawing.Point(232, 128);
this.cbxEnv.Name = "cbxEnv";
this.cbxEnv.Size = new System.Drawing.Size(144, 21);
this.cbxEnv.TabIndex = 3;
//
// txtUser
//
this.txtUser.Location = new System.Drawing.Point(232, 80);
this.txtUser.Name = "txtUser";
this.txtUser.Size = new System.Drawing.Size(144, 20);
this.txtUser.TabIndex = 1;
this.txtUser.Text = "";
//
// txtPwd
//
this.txtPwd.Location = new System.Drawing.Point(232, 104);
this.txtPwd.Name = "txtPwd";
this.txtPwd.PasswordChar = '*';
this.txtPwd.Size = new System.Drawing.Size(144, 20);
this.txtPwd.TabIndex = 2;
this.txtPwd.Text = "";
//
// lblUserName
//
this.lblUserName.Font = new System.Drawing.Font("Microsoft Sans Serif",
8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
this.lblUserName.ForeColor = System.Drawing.Color.MidnightBlue;
this.lblUserName.Location = new System.Drawing.Point(128, 80);
this.lblUserName.Name = "lblUserName";
this.lblUserName.TabIndex = 0;
this.lblUserName.Text = "User Name:";
this.lblUserName.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// lblPwd
//
this.lblPwd.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
this.lblPwd.ForeColor = System.Drawing.Color.MidnightBlue;
this.lblPwd.Location = new System.Drawing.Point(128, 104);
this.lblPwd.Name = "lblPwd";
this.lblPwd.TabIndex = 0;
this.lblPwd.Text = "Password:";
this.lblPwd.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// lblEnv
//
this.lblEnv.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
this.lblEnv.ForeColor = System.Drawing.Color.MidnightBlue;
this.lblEnv.Location = new System.Drawing.Point(128, 128);
this.lblEnv.Name = "lblEnv";
this.lblEnv.TabIndex = 0;
this.lblEnv.Text = "Database:";
this.lblEnv.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// sbLogin
//
this.sbLogin.Enabled = false;
this.sbLogin.Font = new System.Drawing.Font("Microsoft Sans Serif", 6F,
System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
this.sbLogin.Location = new System.Drawing.Point(0, 216);
this.sbLogin.Name = "sbLogin";
this.sbLogin.Size = new System.Drawing.Size(472, 16);
this.sbLogin.SizingGrip = false;
this.sbLogin.TabIndex = 0;
this.sbLogin.Text = "Ready";
//
// pictureBox1
//
this.pictureBox1.Image =
((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(40, 64);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(64, 104);
this.pictureBox1.TabIndex = 6;
this.pictureBox1.TabStop = false;
//
// label1
//
this.label1.BackColor = System.Drawing.Color.AliceBlue;
this.label1.Dock = System.Windows.Forms.DockStyle.Top;
this.label1.Font = new System.Drawing.Font("Arial", 12F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
this.label1.ForeColor = System.Drawing.Color.MidnightBlue;
this.label1.Location = new System.Drawing.Point(0, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(472, 48);
this.label1.TabIndex = 0;
this.label1.Text = "Film Managment Reporting Systems";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// ubtnChangePwd
//
this.ubtnChangePwd.ButtonStyle =
Infragistics.Win.UIElementButtonStyle.Flat;
this.ubtnChangePwd.Font = new System.Drawing.Font("Microsoft Sans Serif",
8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
this.ubtnChangePwd.Location = new System.Drawing.Point(312, 176);
this.ubtnChangePwd.Name = "ubtnChangePwd";
this.ubtnChangePwd.TabIndex = 7;
this.ubtnChangePwd.Text = "Password";
this.ubtnChangePwd.Click += new
System.EventHandler(this.ubtnChangePwd_Click);
//
// frmSplash
//
this.AcceptButton = this.ubtnLogIn;
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.BackColor = System.Drawing.Color.WhiteSmoke;
this.CancelButton = this.ubtnCancel;
this.ClientSize = new System.Drawing.Size(472, 232);
this.Controls.Add(this.ubtnChangePwd);
this.Controls.Add(this.label1);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.sbLogin);
this.Controls.Add(this.lblEnv);
this.Controls.Add(this.lblPwd);
this.Controls.Add(this.lblUserName);
this.Controls.Add(this.txtPwd);
this.Controls.Add(this.txtUser);
this.Controls.Add(this.cbxEnv);
this.Controls.Add(this.ubtnCancel);
this.Controls.Add(this.ubtnLogIn);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "frmSplash";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Film Management Systems";
this.Load += new System.EventHandler(this.frmSplash_Load);
this.ResumeLayout(false);

}
#endregion

private void ubtnLogIn_Click(object sender, System.EventArgs e)
{

string ConnectionString ="";
frmPassword frmPwd;
DialogResult pwd;


this.sbLogin.Text = "Connecting to the " + this.cbxEnv.Text+ "
Database...";

//get the connectionstring from app.config
AppSettingsReader asr = new AppSettingsReader();
ConfigurationSettings.GetConfig("appSettings");
ConnectionString =
ConfigurationSettings.AppSettings.Get(this.cbxEnv.Text);

//(string) asr.GetValue(this.cbxEnv.Text, typeof(string));
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top