gpt4 book ai didi

c# - 使用输出参数执行 MySqlCommand (StoredProcedure)

转载 作者:行者123 更新时间:2023-11-29 07:07:45 27 4
gpt4 key购买 nike

我不知道如何使用 Connector/NET 3.6.5 提供的 MySQLCommand。基本上这里是我正在使用的代码和我在运行 ExecuteNonQuery 时得到的异常。我在这里做错了什么?我没有想法了:(

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();

异常

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;

关于c# - 使用输出参数执行 MySqlCommand (StoredProcedure),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6319642/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com