// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.LinkButton1.Click += new System.EventHandler(this.LinkButton1_Click);
this.DataGrid1.Disposed += new System.EventHandler(this.DataGrid1_Disposed);
this.DataGrid1.CancelCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_CancelCommand);
this.DataGrid1.EditCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_EditCommand);
this.DataGrid1.UpdateCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_UpdateCommand);
this.DataGrid1.DeleteCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_DeleteCommand);
this.DataGrid1.SelectedIndexChanged += new System.EventHandler(this.DataGrid1_SelectedIndexChanged);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void LinkButton1_Click(object sender, System.EventArgs e)
{
AddPublisher();
}
/// <summary>
/// 添加
/// </summary>
private void AddPublisher()
{
string sql="insert into publishers(pub_id,pub_name,city,state,country) values(@pubid,@pubname,@city,@state,@country)";
SqlConnection con=new SqlConnection("server=accp-lzh;uid=sa;pwd=sasa;database=pubs");
SqlCommand cmd=new SqlCommand(sql,con);
cmd.Parameters.Add(new SqlParameter("@pubid",SqlDbType.Char,4));
cmd.Parameters["@pubid"].Value=this.TextBox1.Text;
cmd.Parameters.Add(new SqlParameter("@pubname",SqlDbType.VarChar ,40));
cmd.Parameters["@pubname"].Value=this.TextBox2.Text;
cmd.Parameters.Add(new SqlParameter("@city",SqlDbType.Char,20));
cmd.Parameters["@city"].Value=this.TextBox3.Text;
cmd.Parameters.Add(new SqlParameter("@state",SqlDbType.Char,2));
cmd.Parameters["@state"].Value=this.TextBox4.Text;
cmd.Parameters.Add(new SqlParameter("@country",SqlDbType.VarChar ,30));
cmd.Parameters["@country"].Value=this.TextBox5.Text;
cmd.Connection.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.LinkButton1.Click += new System.EventHandler(this.LinkButton1_Click);
this.DataGrid1.Disposed += new System.EventHandler(this.DataGrid1_Disposed);
this.DataGrid1.CancelCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_CancelCommand);
this.DataGrid1.EditCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_EditCommand);
this.DataGrid1.UpdateCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_UpdateCommand);
this.DataGrid1.DeleteCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_DeleteCommand);
this.DataGrid1.SelectedIndexChanged += new System.EventHandler(this.DataGrid1_SelectedIndexChanged);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void LinkButton1_Click(object sender, System.EventArgs e)
{
AddPublisher();
}
/// <summary>
/// 添加
/// </summary>
private void AddPublisher()
{
string sql="insert into publishers(pub_id,pub_name,city,state,country) values(@pubid,@pubname,@city,@state,@country)";
SqlConnection con=new SqlConnection("server=accp-lzh;uid=sa;pwd=sasa;database=pubs");
SqlCommand cmd=new SqlCommand(sql,con);
cmd.Parameters.Add(new SqlParameter("@pubid",SqlDbType.Char,4));
cmd.Parameters["@pubid"].Value=this.TextBox1.Text;
cmd.Parameters.Add(new SqlParameter("@pubname",SqlDbType.VarChar ,40));
cmd.Parameters["@pubname"].Value=this.TextBox2.Text;
cmd.Parameters.Add(new SqlParameter("@city",SqlDbType.Char,20));
cmd.Parameters["@city"].Value=this.TextBox3.Text;
cmd.Parameters.Add(new SqlParameter("@state",SqlDbType.Char,2));
cmd.Parameters["@state"].Value=this.TextBox4.Text;
cmd.Parameters.Add(new SqlParameter("@country",SqlDbType.VarChar ,30));
cmd.Parameters["@country"].Value=this.TextBox5.Text;
cmd.Connection.
| 对此文章发表了评论 |

