加入收藏 | 设为首页 | 会员中心 | 我要投稿 PHP编程网 - 黄冈站长网 (http://www.0713zz.com/)- 数据应用、建站、人体识别、智能机器人、语音技术!
当前位置: 首页 > 站长学院 > Asp教程 > 正文

asp.net Accee数据库连接不稳定解决方案

发布时间:2021-07-14 00:57:20 所属栏目:Asp教程 来源:互联网
导读:副标题#e# 错误信息如下: 写了如下的一个方法来返回数据操作影响的行数:如下 复制代码 代码如下: private int GetReturnValue(string sStr, string conn) { OleDbConnection odbconn = AccessHelp(conn); OleDbCommand odbcmd = new OleDbCommand(sStr, o


private static void PrepareCommand(OldbCommand command, OldbConnection connection, OldbTransaction transaction, CommandType commandType, string commandText, SqlParameter[] commandParameters, out bool mustCloseConnection) {
if (command == null) throw new ArgumentNullException("command");
if (commandText == null || commandText.Length == 0) throw new ArgumentNullException("commandText");
// If the provided connection is not open, we will open it
if (connection.State != ConnectionState.Open) {
mustCloseConnection = true;
connection.Open();
}
else {
mustCloseConnection = false;
}
// Associate the connection with the command
command.Connection = connection;
// Set the command text (stored procedure name or SQL statement)
command.CommandText = commandText;
//Set the command Time
command.CommandTimeout = 60;
// If we were provided a transaction, assign it
if (transaction != null) {
if (transaction.Connection == null) throw new ArgumentException("The transaction was rollbacked or commited, please provide an open transaction.", "transaction");
command.Transaction = transaction;
}
// Set the command type
command.CommandType = commandType;
// Attach the command parameters if they are provided
if (commandParameters != null) {
AttachParameters(command, commandParameters);
}
return;
}


上面是我用的那个类,修改的时间位置。已经用背景标出来了。
呵呵,这个连接不稳定的问题到此就结束了。
本文专业技术是ASP.Net开发,在次谢谢你对我的博客的关注。
有问题也可以加我Q我哦。

(编辑:PHP编程网 - 黄冈站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

推荐文章
    热点阅读