2

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_viewsCount", 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)
3
  • can you post the signature of the called stored procedure Commented Jun 12, 2011 at 1:57
  • 3
    make sure that the parameter types are mapped correctly to the types used in the stored procedure. Commented Jun 12, 2011 at 1:58
  • 1
    :D So great to have somebody smart around. Had to use MySqlDbType instead. Commented Jun 12, 2011 at 2:08

1 Answer 1

3
 MySqlCommand command = new MySqlCommand("PredictPaperRankInInterval", con);
 command .CommandType = System.Data.CommandType.StoredProcedure;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.