Results 1 to 2 of 2

Thread: [RESOLVED] MySQL 5.0 and Vb.NET 2003 problem

  1. #1

    Thread Starter
    Frenzied Member Asgorath's Avatar
    Join Date
    Sep 2004
    Location
    Saturn
    Posts
    2,036

    Resolved [RESOLVED] MySQL 5.0 and Vb.NET 2003 problem

    My stored procedure called devolve_proxima_encomenda doesn't return any values both using a reader or .ExecuteScalar. I am using the .net mysqlclients.
    Code:
    DELIMITER $$
    
    DROP PROCEDURE IF EXISTS devolve_proxima_encomenda$$
    CREATE PROCEDURE devolve_proxima_encomenda()
    BEGIN
        declare num int(10);
        select num = max(numenc)+1 from encomendas;
        if (num is null) then set num =1;
        end if;
        select num;
    END$$
    
    DELIMITER ;

    VB Code:
    1. Imports MySql.Data.MySqlClient
    2.  
    3.         Dim oMySqlConn As New MySqlConnection
    4.         Dim oMySqlCom As New MySqlCommand
    5.         Dim reader As MySqlDataReader
    6.  
    7.         oMySqlConn.ConnectionString = "Server=10.1.1.17;Database=mindsolutions;Uid=root;Pwd=123;"
    8.  
    9.         Try
    10.             oMySqlConn.Open()
    11.             oMySqlCom.Connection = oMySqlConn
    12.             oMySqlCom.CommandType = CommandType.StoredProcedure
    13.             oMySqlCom.CommandText = "devolve_proxima_encomenda"
    14.             oMySqlCom.Parameters.Clear()
    15.  
    16.             ''Console.WriteLine("numenc" & oMySqlCom.ExecuteScalar().ToString)
    17.             reader = oMySqlCom.ExecuteReader
    18.             While reader.Read
    19.                 Console.WriteLine("numero da encomenda=" & reader(0).ToString)
    20.             End While
    21.             reader.Close()
    22.  
    23.         Catch ex As Exception
    24.             MessageBox.Show(ex.Message)
    25.         End Try
    26.         oMySqlConn.Close()

    Regards
    Jorge
    "The dark side clouds everything. Impossible to see the future is."

  2. #2

    Thread Starter
    Frenzied Member Asgorath's Avatar
    Join Date
    Sep 2004
    Location
    Saturn
    Posts
    2,036

    Re: MySQL 5.0 and Vb.NET 2003 problem

    Solved -- mofied mysql procedure to include an OUT statement and modified vb code to use a output parameter.

    Regards
    Jorge
    "The dark side clouds everything. Impossible to see the future is."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width