Hello Friends
I am trying to insert a record into the table: I have written the backend procedure which is working fine. I use only 2 controls and a Insert button.
I have customer ID and Customer name to insert: I have copied and pasted my source code. I have button INSERT. On click of that Button I want to insert.
When I run my program - DBfill procedure is not executed. Please let me know how to call this procedure? to insert value on CLICK on INSERT BUTTON
2) How can write this to Update if I have another button as UPDATE
Please help
My advance thanks
using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{ public void DbFill() {
SqlConnection Conn = new SqlConnection(ConfigurationSettings.AppSettings["Buy4nowConnectionString"].ToString()); Conn.Open();
SqlCommand _cmd = new SqlCommand("InsertCustomer", Conn);
_cmd.CommandType = CommandType.StoredProcedure; _cmd.Parameters.Add(new SqlParameter("@CustId",strCustID.Text)); _cmd.Parameters.Add(new SqlParameter("@customerName",StrCustName.Text)); SqlDataReader _reader = _cmd.ExecuteReader();
Conn.Close();
}
protected void Page_Load(object sender, EventArgs e) {
} protected void btnInsert_Click(object sender, EventArgs e) { } }
|
| Author: Vijaya saradhi 29 Aug 2008 | Member Level: Silver | Rating: Points: 3 |
Hello friend to perform data manipulation operations like insert,update and delete we need to call command object's ExecuteNonquery() method instead of ExecuteReader() method.I think you got my point.
|