troubleshooting Question

Out Param Error

Avatar of Costless
CostlessFlag for Australia asked on
MySQL Server
3 Comments1 Solution2406 ViewsLast Modified:
I've recently installe MySQL 5.0.27

& create a Stored Proc



create procedure insertAircraft(in airlineCode varchar(2), in name varchar(150),in description varchar(255), out newId bigint)

  begin
     INSERT INTO lcc_aircraft (`AIRLINE_CODE`,`NAME`,`DESCRIPTION`) values (airlineCode,name,description);
     commit;
     select @@identity into newId;
  end

This works fine when I add a record via the mysql command prompt
I'm able to pass in the "out" param
and retrieve the value later on
 
---------------------------------

mysql> call insertAircraft('BA','British Airways','Some descript',@x);
Query OK, 0 rows affected (0.03 sec)

mysql> select @x;
+------+
| @x   |
+------+
| 9    |
+------+
1 row in set (0.00 sec)

-----------------------------------------

However from my vb.net code this gives an error:

#42000OUT or INOUT argument 4 for routine gidnet_pak.insertAircraft is not a variable or NEW pseudo-variable in BEFORE trigger


--------------my code--------------

        Dim conn As New MySqlConnection
        Try
            conn.ConnectionString = "xxxxxxxxxxxx my connection str xxxxxxxxxxxxxxxxxxxx"
            Dim myCommand As New MySqlCommand
            myCommand.CommandType = CommandType.StoredProcedure
            myCommand.Connection = conn

            myCommand.Parameters.Add("newId", SqlDbType.BigInt)
            myCommand.Parameters.Add("airlineCode", SqlDbType.VarChar, 2).Value = airlineCode
            myCommand.Parameters.Add("name", SqlDbType.VarChar, 150).Value = name
            myCommand.Parameters.Add("description", SqlDbType.VarChar, 255).Value = description

            conn.Open()

            myCommand.ExecuteNonQuery()

            conn.Close()

            Return myCommand.Parameters.Item("newId").Value
        Catch myerror As MySqlException

        Finally
            conn.Dispose()
        End Try


-------------------- end of code ------------------------



the error happens on the line

 myCommand.ExecuteNonQuery()

so its not even at the point of retrieving the output param value
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros