ConnectionString 属性尚未初始化(我是新手,希望能得到各位的指点)
namespace admin
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Info_Lb;
protected System.Web.UI.WebControls.Label Msg;
protected System.Web.UI.WebControls.TextBox txt_name;
protected System.Web.UI.WebControls.RadioButtonList Rbt_sex;
protected System.Web.UI.WebControls.TextBox txt_idno;
protected System.Web.UI.WebControls.TextBox txt_birth;
protected System.Web.UI.WebControls.TextBox txt_address;
protected System.Web.UI.WebControls.TextBox txt_mobile;
protected System.Web.UI.WebControls.TextBox txt_email;
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
protected System.Web.UI.WebControls.TextBox txt_pass;
protected System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator1;
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator2;
protected System.Web.UI.WebControls.LinkButton btn_OK;
public string editid;
public string type;
public string BindUser;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
private void Initializecomponent()
{
this.btn_OK.Click += new System.EventHandler(this.btn_OK_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.btn_OK.Click += new System.EventHandler(this.btn_OK_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void btn_OK_Click(object sender, System.EventArgs e)
{
string strRealName = this.txt_name.Text.Trim();
string strPassWord = this.txt_pass.Text.Trim();
if(strRealName.Length==0)
{
RequiredFieldValidator1.Enabled=true;
return;
}
if(strPassWord.Length==0)
{
RequiredFieldValidator2.Enabled=true;
}
SqlConnection MyConn = new SqlConnection(ConfigurationSettings.AppSettings[ "strConnection "]);
MyConn.Open();
string sqlstr= "insert into [userinformation](userName,userSex,userAddess,userCard,userEmail,userPhone,userBirthDay, "
+ "values( ' "+this.txt_name.Text + " ', "+ this.Rbt_sex.SelectedValue + ", "
+ this.txt_address.Text + ", "+ this.txt_mobile.Text + ", ' "+ this.txt_email.Text + " ', ' "