更新时间:2021-11-26 22:23:48
你应该首先打开连接,做所有事情。试试下面的内容。
You should open the connection first, the do everything. Try the below.
using (DbCommand cmd = db.GetStoredProcCommand(sStoredProcName))
{
cmd.Connection = conn;
conn.Open();
// Other codes...
}
大多数情况下(和我一起),这是一个愚蠢的错误。我更专注于BLOB变量,几乎忽略了其余的东西。
我正在做
As it happens most of the time (with me), it was a silly mistake. I was concentrating more on the BLOB variable and almost ignored the rest of the stuff.
I was doing
db.ExecuteNonQuery(cmd);
并且此后连接正在关闭。我将我的代码更改为
and the connection was getting closed just after this. I changed my code to
cmd.ExecuteNonQuery();
,现在工作正常。
希望这会帮助别人并节省一些时间。
干杯,
迪帕克
and its working fine now.
Hope this will help someone else and will save some time.
Cheers,
Deepak