Advertisement
panxop

Untitled

Nov 22nd, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.65 KB | None | 0 0
  1.    public int CONSULTA_MON_X_NUM_OPC(int NUM_OPC)
  2.         {
  3.             ClsConexion con = new ClsConexion();
  4.             SqlConnection connection = new SqlConnection(con.DB_ConnectionString);
  5.             SqlDataAdapter adapter = new SqlDataAdapter();
  6.             SqlCommand command;
  7.             DataSet ds = new DataSet();
  8.  
  9.             try
  10.             {
  11.                 command = new SqlCommand("SP_CONSULTA_MON_X_NUM_OPC");
  12.                 command.CommandType = CommandType.StoredProcedure;
  13.                 command.Parameters.Add("@NUM_OPC", SqlDbType.Int).Value = NUM_OPC;
  14.                 command.Connection = connection;
  15.                 command.CommandTimeout = 0;
  16.                 command.Connection.Open();
  17.                 adapter = new SqlDataAdapter(command);
  18.                 adapter.Fill(ds);
  19.  
  20.                 if (ds.Tables[0].Rows.Count > 0)
  21.                 {
  22.                     return int.Parse(ds.Tables[0].Rows[0]["par_mon"].ToString());
  23.                 }
  24.             }
  25.             catch (SqlException e)
  26.             {
  27.                 clss_log.eLog("-----------------------------------------------------------------------------");
  28.                 clss_log.eLog("Error: " + DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss"));
  29.                 clss_log.eLog("Al intentar ejecutar SP SP_CONSULTA_MON_X_NUM_OPC con el parámetro NUM_OPC: " + NUM_OPC);
  30.                 clss_log.eLog("Error: " + e.Errors);
  31.                 clss_log.eLog("-----------------------------------------------------------------------------");
  32.             }
  33.             finally
  34.             {
  35.                 connection.Close();
  36.             }
  37.             return 0;
  38.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement