我正在使用mysqldatabase并在其中成功创建了storedprocedure。我想在我的c#代码中调用该存储过程。但是当我调用mysqlcommand时,timeout属性自动设置为零。
我读到默认值是30.我试图在c#代码和连接字符串中重置超时属性。但是我收到错误,因为'不支持指定的方法'。
这是什么原因?超时值为零时有问题吗?
答案 0 :(得分:1)
查看源代码(.net的mysql驱动程序):
#if !CF
//[Category("Misc")]
//[Description("Time to wait for command to execute")]
//[DefaultValue(30)]
#endif
public override int CommandTimeout
{
get { return useDefaultTimeout ? 30 : commandTimeout; }
set
{
if (commandTimeout < 0)
throw new ArgumentException("Command timeout must not be negative");
// Timeout in milliseconds should not exceed maximum for 32 bit
// signed integer (~24 days), because underlying driver (and streams)
// use milliseconds expressed ints for timeout values.
// Hence, truncate the value.
int timeout = Math.Min(value, Int32.MaxValue / 1000);
if (timeout != value)
{
MySqlTrace.LogWarning(connection.ServerThread,
"Command timeout value too large ("
+ value + " seconds). Changed to max. possible value ("
+ timeout + " seconds)");
}
commandTimeout = timeout;
useDefaultTimeout = false;
}
}