Quantcast
Channel: MySQL Forums - Connector/NET and C#, Mono, .Net
Viewing all articles
Browse latest Browse all 1451

MySQL Stored Procedures called from C# not returning any rows (no replies)

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

Viewing all articles
Browse latest Browse all 1451

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>