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:-))
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:-))