mesutd0nmez
10/28/2016 - 9:23 AM

How to call Store Precedure

How to call Store Precedure

public DataSet GenelAlimListesiRaporu(Int16 depositorId,Int16 requestTypeId)
{
  //@DepositorId
  //@RequestTypeId
  //@AcquireDate
  //@IsMobile
  //@BoutiqueSupplierRegionNo
  //@ProductTypeId
  //@DriverId
  //@PlateNo
  //@IsSpotVehicle
  //@IsHanger
  //@ReturnTypeId

  System.Data.DataSet dset = new System.Data.DataSet();
  string connString = "";
  using (var db = new VehiclePlannerContext())
  {
      connString = db.Database.Connection.ConnectionString;
  }

  SqlConnection myConnection = new SqlConnection(connString);

  myConnection.Open();

  SqlCommand mycommand = new SqlCommand();
  System.Data.SqlClient.SqlDataAdapter adp = new System.Data.SqlClient.SqlDataAdapter();

  mycommand.CommandType = CommandType.StoredProcedure;
  mycommand.Connection = myConnection;

  mycommand.CommandText = "sp_GenelAlimListesi_rpt";

  mycommand.Parameters.Add("@DepositorId", SqlDbType.SmallInt);
  mycommand.Parameters["@DepositorId"].Value = depositorId;

  mycommand.Parameters.Add("@RequestTypeId", SqlDbType.SmallInt);
  mycommand.Parameters["@RequestTypeId"].Value = requestTypeId;

  
  //   Create a data adapter to store the inforamtion
  adp = new System.Data.SqlClient.SqlDataAdapter();
  dset = new DataSet();

  adp.SelectCommand = mycommand;
  adp.Fill(dset, "Results");

  
  myConnection.Close();
  return dset;
}