HernanBogantes 0 Newbie Poster

Hi,

I really need your help. And I really will appreciate it also.

By using ASP.NET I need to show in a Label or in a gridview control the output parameter of an “Stored Procedure”

ERROR: Parameter 'RESULTADO' not found in the collection.

PLEASE Help

‘****************************************************************************************
DELIMITER $$
DROP PROCEDURE IF EXISTS `nombre` $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `nombre`(
IN condicion VARCHAR(10),
OUT RESULTADO VARCHAR (10))
BEGIN
SELECT nombre
INTO RESULTADO
FROM franja
where topico = condicion;
END $$
DELIMITER ;
‘****************************************************************************************
‘****************************************************************************************
Dim hilera As String = "Server=localhost;Database=parrilla_comercial;Uid= root;Pwd= conectar;"
Dim conexion As MySqlConnection = New MySqlConnection(hilera)
Try
conexion.Open()
Dim comando As MySqlCommand = New MySqlCommand()
comando.CommandType = CommandType.StoredProcedure
comando.CommandText = "nombre"
comando.Connection = conexion

Dim p As MySqlParameter = New MySqlParameter()
p.MySqlDbType = SqlDbType.NVarChar
p.Value = TextBox1.Text
p.Direction = ParameterDirection.Input
p.ParameterName = "@condicion"
comando.Parameters.Add(p)
comando.ExecuteScalar()

Dim r As MySqlParameter = New MySqlParameter()
r.Direction = ParameterDirection.Output
r.ParameterName = "@RESULTADO"
comando.Parameters.Add(r)
comando.ExecuteScalar()
Label2.Text = comando.Parameters("@RESULTADO").Value.ToString
Catch ex As Exception
Label1.Text = ex.Message
Finally
If conexion.State = ConnectionState.Open Then
conexion.Close()
End If
End Try
‘****************************************************************************************

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.