Ver Mensaje Individual
  #3 (permalink)  
Antiguo 31/05/2013, 10:35
Avatar de aid_val
aid_val
 
Fecha de Ingreso: mayo-2013
Ubicación: Guanajuato
Mensajes: 302
Antigüedad: 11 años, 6 meses
Puntos: 5
Respuesta: ¿Como llamar un procedimiento almacenado en asp?

Hola que tal, creo que a tu codigo le hacen falta atributos te dejo un ejemplo que me sirve mucho para todo tipo de consulta

Public Function CreateCustomerAdapter( _
ByVal connection As SqlConnection) As SqlDataAdapter

Dim adapter As SqlDataAdapter = New SqlDataAdapter()

' Create the SelectCommand.
Dim command As SqlCommand = New SqlCommand( _
"SELECT * FROM Customers " & _
"WHERE Country = @Country AND City = @City", connection)

' Add the parameters for the SelectCommand.
command.Parameters.Add("@Country", SqlDbType.NVarChar, 15)
command.Parameters.Add("@City", SqlDbType.NVarChar, 15)

adapter.SelectCommand = command

' Create the InsertCommand.
command = New SqlCommand( _
"INSERT INTO Customers (CustomerID, CompanyName) " & _
"VALUES (@CustomerID, @CompanyName)", connection)

' Add the parameters for the InsertCommand.
command.Parameters.Add("@CustomerID", SqlDbType.NChar, 5, "CustomerID")
command.Parameters.Add("@CompanyName", SqlDbType.NVarChar, 40, "CompanyName")

adapter.InsertCommand = command

' Create the UpdateCommand.
command = New SqlCommand( _
"UPDATE Customers SET CustomerID = @CustomerID, CompanyName = @CompanyName " & _
"WHERE CustomerID = @oldCustomerID", connection)

' Add the parameters for the UpdateCommand.
command.Parameters.Add("@CustomerID", SqlDbType.NChar, 5, "CustomerID")
command.Parameters.Add("@CompanyName", SqlDbType.NVarChar, 40, "CompanyName")
Dim parameter As SqlParameter = command.Parameters.Add( _
"@oldCustomerID", SqlDbType.NChar, 5, "CustomerID")
parameter.SourceVersion = DataRowVersion.Original

adapter.UpdateCommand = command

' Create the DeleteCommand.
command = New SqlCommand( _
"DELETE FROM Customers WHERE CustomerID = @CustomerID", connection)

' Add the parameters for the DeleteCommand.
command.Parameters.Add( _
"@CustomerID", SqlDbType.NChar, 5, "CustomerID")
parameter.SourceVersion = DataRowVersion.Original

adapter.DeleteCommand = command

Return adapter
End Function