
06/04/2009, 09:41
|
 | | | Fecha de Ingreso: febrero-2009 Ubicación: Coahuila, México
Mensajes: 145
Antigüedad: 16 años, 1 mes Puntos: 1 | |
Respuesta: llenar dataSet con Store Procedure Cita:
Iniciado por Dradi7 Puedes Usar Tambien de Esta Forma
public DataTable MostrarConsulta(int Mes,int Anyo)
{
SqlDataAdapter Adp = new SqlDataAdapter(); // Variable q me Tomara Los Datos
SqlParameter Par = new SqlParameter(); // Variable para la Recepcion de Datos
DataSet Datos = new DataSet(); // Creando un DataSet
try
{
Adp.SelectCommand = new SqlCommand(); // Creando una Instancia de SqlCommand
Adp.SelectCommand.Connection = Con; // Indicale tu variable de conexion ojo debes estar conectado a la Base de Datos Primero
Adp.SelectCommand.CommandText = "NOM_PROC"; // Indicamos el nombre del Proc Alm.
Adp.SelectCommand.CommandType = CommandType.StoredProcedure; // Le Decimos q es de Tipo Procedure
Par = Adp.SelectCommand.Parameters.Add("@Mes", SqlDbType.Int, 4); // Creando parametro
Par.Value = 4; // aqui le puedes cambiar por una variable
Par = Adp.SelectCommand.Parameters.Add("@Anyo", SqlDbType.Int, 4);// Creando parametro
Par.Value = 2009; // aqui le puedes cambiar por una variable
Adp.Fill(Datos, "x"); // Ejecutando y Recibiendo la consulta devuelta
}
catch(Exception e){MessageBox.show(null,e.Message,"Aviso");}
return Datos.Tables["x"];
} Tengo problemas!!
No guarda nada en el datatable....
Código:
Dim oConn As SqlConnection
oConn = New SqlConnection("Server=server\sqlexpress;integrated security=true;database=databases;uid=;pwd=;")
Dim table As New DataTable
Dim Adp As New SqlDataAdapter()
Adp.SelectCommand = New SqlCommand() ' Creando una Instancia de SqlCommand
Adp.SelectCommand.Connection = oConn 'Conexión
Adp.SelectCommand.CommandText = "s_proc_SP"
'oConn.Open()
Adp.SelectCommand.CommandType = CommandType.StoredProcedure
Adp.SelectCommand.Parameters.Add("@año", SqlDbType.Int, 4)
Adp.SelectCommand.Parameters("@año").Value = ano
Adp.SelectCommand.Parameters.Add("@mes", SqlDbType.Int, 4)
Adp.SelectCommand.Parameters("@mes").Value = mes
Adp.Fill(table)
reportGD.DataSource = table
Me pudieran ayudar a identificar mi error,,
Gracias... |