Sql Command Cmdnew

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Sql Command Cmdnew as PDF for free.

More details

  • Words: 261
  • Pages: 2
SqlCommand cmdNew this.sqlConnection1);

= new SqlCommand("ProcessNewOrder", SqlDataAdapter sdaNew = new SqlDataAdapter(cmdNew); // Let the SQL command know the type of command we are

going to use // In this case, it is a stored procedure cmdNew.CommandType = CommandType.StoredProcedure; // We will need a SQL parameter to carry the arguments // Declare its variable SqlParameter parNew = new SqlParameter(); // Specify the name of the argument parNew.ParameterName = "@ProcessedBy"; // Specify the SQL data type of the argument parNew.SqlDbType = SqlDbType.Int; // Specify the value passed as argument parNew.Value = this.cboProcessedBy.SelectedIndex; // Once the argument is ready, add it to the list of arguments cmdNew.Parameters.Add(parNew); parNew = new SqlParameter(); parNew.ParameterName = "@DateOrdered"; parNew.SqlDbType = SqlDbType.SmallDateTime; parNew.Value = this.dtpOrderDate.Value; cmdNew.Parameters.Add(parNew); parNew = new SqlParameter(); parNew.ParameterName = "@TimeOrdered"; parNew.SqlDbType = SqlDbType.SmallDateTime; parNew.Value = this.dtpOrderTime.Value; cmdNew.Parameters.Add(parNew); parNew = new SqlParameter(); parNew.ParameterName = "@ContainerType"; parNew.SqlDbType = SqlDbType.Int; parNew.Value = this.cboContainer.SelectedIndex; cmdNew.Parameters.Add(parNew); parNew = new SqlParameter(); parNew.ParameterName = "@SelectedFlavor"; parNew.SqlDbType = SqlDbType.Int; parNew.Value = this.cboFlavor.SelectedIndex; cmdNew.Parameters.Add(parNew);

parNew = new SqlParameter(); parNew.ParameterName = "@NbrOfScoops"; parNew.SqlDbType = SqlDbType.Int; parNew.Value = int.Parse(this.txtScoops.Text); cmdNew.Parameters.Add(parNew); parNew = new SqlParameter(); parNew.ParameterName = "@WhatIngredient"; parNew.SqlDbType = SqlDbType.Int; parNew.Value = this.cboIngredient.SelectedIndex; cmdNew.Parameters.Add(parNew); // Inform the user about the action that is going to occur // (You can also do this after the action has been carried MessageBox.Show("A new customer order has been created"); // Update the data set with the new information from the data adapter sdaNew.Fill(this.dsOrders1, "Orders"); // Change the caption of the button to inform the user this.btnNewOrder.Text = "New Order"; // And move to the last record this.BindingContext[this.dsOrders1, "Orders"].Position = this.BindingContext[this.dsOrders1, "Orders"].Count

Related Documents