K
Kevin Yu [MSFT]
Hi Mal,
IMO, the update method in Customer class should not have any arguments.
Because calling Update is updating the very object you're calling this
method on. You can change the method to
public void Update()
{
try
{
SqlConnection con = new
SqlConnection(ConfigurationManager.ConnectionStrings["ToolkitServer"].Connec
tionString);
SqlCommand cmd = new SqlCommand("updatecustomer", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@customerid", SqlDbType.Int);
cmd.Parameters["@customerid"].Value = this.CustomerID;
cmd.Parameters.Add("@customername", SqlDbType.NVarChar);
cmd.Parameters["@customername"].Value = this.CustomerName;
cmd.Parameters.Add("@address1", SqlDbType.NVarChar);
cmd.Parameters["@address1"].Value = this.Address1;
//................................
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
catch (Exception ex)
{
}
}
Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
IMO, the update method in Customer class should not have any arguments.
Because calling Update is updating the very object you're calling this
method on. You can change the method to
public void Update()
{
try
{
SqlConnection con = new
SqlConnection(ConfigurationManager.ConnectionStrings["ToolkitServer"].Connec
tionString);
SqlCommand cmd = new SqlCommand("updatecustomer", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@customerid", SqlDbType.Int);
cmd.Parameters["@customerid"].Value = this.CustomerID;
cmd.Parameters.Add("@customername", SqlDbType.NVarChar);
cmd.Parameters["@customername"].Value = this.CustomerName;
cmd.Parameters.Add("@address1", SqlDbType.NVarChar);
cmd.Parameters["@address1"].Value = this.Address1;
//................................
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
catch (Exception ex)
{
}
}
Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."