How do I update SQL Database via stored procedures in WPF?
Please bear with me while i explain my question. I think it will make more sense. Thank you:
I have a table in SQL server 2005 with three columns CustomerID (integer, identity), Name(varchar(50) and Address(varchar(50). I created four stored procedures for the table (CustomerSelect, CustomerInsert, CustomerDelete and CustomerUpdate).
In VS 2008, i created a connection string to the table using Settings.settings. I then created a Data Access Class with the following code to enable me sellect and view a customer in the database:
public class CustomerDAL
private string connectionString = Properties.Settings.Default.BranchAppConnString;
public Branch SelectCustomer(int ID)
SqlConnection conn = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand("CustomerSelect", conn);
cmd.CommandType = CommandType.StoredProcedure;
SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow);
Customer customer = new Customr((string)reader["CustomerName"], (string)reader["address"]);
Now i created Data Class (Customer) with the properties for the Customer Entity. I also exposed the CustomerDAL class to the application using a partial class. Now this works just fine. I can insert a Customer ID in a text box and click a botton to view the customer.
My question is: How can i use the same pattern to insert, delete and update the customer table via the corresponding stored procedures?