Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //add the new recipie to the database
- protected void Button1_Click(object sender, EventArgs e)
- {
- string recipie_name = TextBox_RecipeName.Text;
- string recipie_instruction = TextBox_RecipeInstructions.Text;
- int recipie_category_id = DropDownCategory.SelectedValue;
- try
- {
- Database db = DatabaseFactory.CreateDatabase("App_Con_str");
- string SQLAddRecipie = "INSERT INTO recipies VALUES(@name, @instructions, @category_id)";
- DbCommand dbCommand = db.GetSqlStringCommand(SQLAddRecipie);
- db.AddInParameter(dbCommand, "name", DbType.String, recipie_name);
- db.AddInParameter(dbCommand, "instructions", DbType.String, recipie_instruction);
- db.AddInParameter(dbCommand, "category_id", DbType.String, recipie_category_id);
- db.ExecuteNonQuery(dbCommand);
- Response.Write("Your recipie has been added");
- }
- catch (DbException)
- {
- throw;
- }
- }
Add Comment
Please, Sign In to add comment