Ver Mensaje Individual
  #2 (permalink)  
Antiguo 03/01/2011, 16:41
humb3rt0x
 
Fecha de Ingreso: febrero-2010
Mensajes: 24
Antigüedad: 14 años, 2 meses
Puntos: 0
Respuesta: sqlCommand ..ayuda porfavor

Estimado compañero espero que esto te ayude:
Código ASP:
Ver original
  1. public static DataTable GetData()
  2.         {
  3.  
  4.  
  5.             SqlConnection myconn;
  6.             myconn=new SqlConnection();
  7.  
  8.             DataTable Mydata;
  9.             Mydata = new DataTable();
  10.  
  11.             myconn.ConnectionString = "Data Source=HMORI\\HUMBERTO3;Initial Catalog=csharp;Integrated Security=True";
  12.  
  13.             SqlCommand mycommand;
  14.  
  15.             mycommand = new SqlCommand();
  16.  
  17.             mycommand.CommandType = CommandType.StoredProcedure;
  18.  
  19.                 mycommand.CommandText="sp_codcli";
  20.  
  21.  
  22.                 mycommand.Connection = myconn;
  23.                 try
  24.                 {
  25.                     mycommand.Parameters.Add("@parametro01", SqlDbType.Int).Value = 6;
  26.  
  27.                     mycommand.ExecuteNonQuery();
  28.  
  29.  
  30.  
  31.                 }
  32.                 catch (Exception error)
  33.                 {
  34.  
  35.                     throw new Exception();
  36.  
  37.                 }
  38.                 finally
  39.                 {
  40.                     myconn.Open();
  41.  
  42.                 }
  43.  
  44.  
  45.  
  46.  
  47.             return Mydata;
  48.  
  49.         }