private OleDbCommand CreateCommand(string SQLstring, CommandType CommandType, string[,] SqlParams, object[] values) { try { myDBConvert = new TypeConvert(); OleDbCommand cmd = new OleDbCommand(); while (true) { if (ConnQueue.Count > 0) { cmd.Connection = ConnQueue.Dequeue(); if (cmd.Connection.State != ConnectionState.Open) { cmd.Connection.Open(); } cmd.Transaction = cmd.Connection.BeginTransaction(); break; } } //if (inTransaction) //{ // cmd.Transaction = trans; //} if ((SqlParams != null) && (SqlParams.GetLength(0) != values.Length)) { throw new Exception("查询的参数与参数值的数量不一致!"); } cmd.CommandType = CommandType; cmd.CommandText = SQLstring; if (SqlParams != null && values != null) { int length = SqlParams.GetLength(0); for (int i = 0; i < length; i++) { if (SqlParams[i, 2] == "") { cmd.Parameters.Add(SqlParams[i, 0], myDBConvert.ConvertOleDB(SqlParams[i, 1])); } else { cmd.Parameters.Add(SqlParams[i, 0], myDBConvert.ConvertOleDB(SqlParams[i, 1]), int.Parse(SqlParams[i, 2]), SqlParams[i, 3]); } if (SqlParams[i, 4] == "Output") { cmd.Parameters[SqlParams[i, 0]].Direction = ParameterDirection.Output; } else { cmd.Parameters[SqlParams[i, 0]].Value = values[i]; } } } return(cmd); } catch (Exception exp) { //throw new Exception(exp); return(null); } }