MySQL Stored Procedures called from C# not returning any rows
Posted by: Martin Michaelsen
Date: February 01, 2018 08:03AM

I am trying to convert my backend from using inline SQL to Stored Procedures.
When testing i MySQL Workbench I get rows back but when I try from my .Net code I get no rows.

Stored Procedure:
CREATE DEFINER=`root`@`localhost` PROCEDURE `get_session`(IN SessionId int)
BEGIN
SELECT * FROM Sessions S
WHERE S.SessionId =@SessionId;
END

C# code:
MySqlCommand cmd = new MySqlCommand("get_session", connection);
cmd.CommandType = CommandType.StoredProcedure;

cmd.Parameters.AddWithValue("@SessionId", sessionId);

MySqlDataReader dataReader = cmd.ExecuteReader();
while (dataReader.Read())
{
s.SessionId = sessionId;

}
I get no errors (I will get an exception if I give a wrong Parameter name) and the dataReader comes back empty handet no matter what.

I am trying this towards localhost on MySQL 5.7.20.

Please help before I go nuts (I may already have:-))

Options: ReplyQuote


Subject
Written By
Posted
MySQL Stored Procedures called from C# not returning any rows
February 01, 2018 08:03AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.