开发者

Executing MySqlCommand (StoredProcedure) with output parameter

I can't figure out how to use MySQLCommand provided by Connector/NET 3.6.5. Basically here is the code I'm using and exception I get when I run ExecuteNonQuery. What am I doing wrong here? I have no ideas left :(

var connection = GetConnection();
connection.Open();

var command = new MySqlCommand("PredictPaperRankInInterval", connection);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add(new MySqlParameter("p_journalId", SqlDbType.VarChar) { Value = "test" });
command.Parameters.Add(new MySqlParameter("p_publishDate", SqlDbType.DateTime) { Value = paper.PublishDate });
command.Parameters.Add(new MySqlParameter("p_intervalInDays", SqlDbType.Int) { Value = 7 });
command.Parameters.Add(new MySqlParameter("p_vie开发者_如何学运维wsCount", SqlDbType.Int) { Value = paper.ViewsCount });
var rank = new MySqlParameter("p_rank", SqlDbType.Int) { Direction = ParameterDirection.Output };
command.Parameters.Add(rank);

command.ExecuteNonQuery();

Exception

Input string was not in a correct format.

DDL

CREATE PROCEDURE `PredictPaperRankInInterval`(IN p_journalId VARCHAR(32), 
                                              IN p_publishDate DATETIME, 
                                              IN p_intervalInDays INT, 
                                              IN p_viewsCount INT, 
                                              OUT p_rank INT)


 MySqlCommand command = new MySqlCommand("PredictPaperRankInInterval", con);
 command .CommandType = System.Data.CommandType.StoredProcedure;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜