Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

VB.NET to mySQL stored procedure problem

Options
  • 16-02-2007 11:08am
    #1
    Registered Users Posts: 7,677 ✭✭✭


    Hi,

    I have got a new laptop and trying to move my assignment onto it.

    I am using VS Dev Edition Express and MySQL 5 with SQLyog.

    I have downloader the connector 5.0.3 and everything works fine when I don't have any parameters to pass into the store procedure.

    If i have a paramter to pass in I am getting the following error.

    System.ArgumentException: Parameter '?strAirportFrom' is not found but a parameter with the name 'strAirportFrom' is found. Parameter names must include the leading parameter marker.
    at MySql.Data.MySqlClient.MySqlParameterCollection.GetParameter(String parameterName)


    Everything was working fine on my old laptop.

    The OS i am using is Vista I have XP Pro on my old laptop (Screen went on it)

    The code is as follows
    
    Public Function getAirportTo(ByVal strAirportFrom As String) As FormControls
            Dim xsdAirport As New FormControls
            Dim oComm As MySqlCommand
            Dim MySqlConn As New MySQLConnect
    
            Try
                Dim myConn As New MySqlConnection
                myConn = MySqlConn.CreateConnection()
    
                myConn.Open()
    
                oComm = New MySqlCommand(GET_AIRPORTS_TO, myConn)
                With oComm
    
                    .CommandType = CommandType.StoredProcedure
                    .Parameters.Add("strAirportFrom", SqlDbType.VarChar, 3)
                    .Parameters("strAirportFrom").Value = strAirportFrom
                End With
                Dim da As New MySqlDataAdapter(oComm)
    
                da.Fill(xsdAirport, "AirportTo")
    
                da = Nothing
                oComm = Nothing
                myConn.Close()
            Catch myEx As MySqlException
                MsgBox("Database connection Error" & myEx.Message)
            End Try
    
            Return xsdAirport
        End Function
    
    
    DELIMITER $$
    
    DROP PROCEDURE IF EXISTS `travelagg`.`spGetAirportTo`$$
    
    CREATE DEFINER=`root`@`localhost` PROCEDURE `spGetAirportTo`(in strAirportFrom varchar(3))
    BEGIN
     select 
     Distinct(a.Airportcode), a.AirportName 
     from 
     Airport a, airportfromto b 
     where 
     b.AirportCodeFrom = strAirportFrom and b.AirportCodeTo = a.Airportcode;
     END$$
    
    DELIMITER ;
    
    

    Thanks


Comments

  • Registered Users Posts: 2,781 ✭✭✭amen


    I recently had a similar problem with C# and MySQL drivers.
    Go back to the prior driver version. I think the 5.0.3 has some issues. There are several discussion on the MySQL website about the .Net drivers.

    The driver seems to think that all parameters are prefixed with a ? in the SPs.


Advertisement