public override DataTable ExecuteQuery(string cmdText, DBHelperParmCollection parameters) { DataTable dtRet = new DataTable(); OdbcCommand _OdbcCommand = (OdbcCommand)CreateCommand(cmdText, CommandType.Text); _OdbcCommand.Parameters.Clear(); if (parameters != null) { foreach (DBHelperParm para in parameters) { _OdbcCommand.Parameters.Add(new OdbcParameter("?" + para.Key, para.Value)); } } OdbcDataAdapter _OdbcDataAdapter = new OdbcDataAdapter(_OdbcCommand); try { _OdbcDataAdapter.Fill(dtRet); } catch (Exception ex) { throw ex; } return(dtRet); }
/// <summary> /// 执行存储过程,返回结果数据 /// </summary> /// <param name="procedureName">过程名</param> public override DataTable ExecuteProcedureQuery(string procedureName, DBHelperParmCollection parameters) { try { DataTable dtbRtn = new DataTable(); string realProcedureName = string.Format("{{CALL {0} (", procedureName); for (int i = 0; i < parameters.Count; i++) { realProcedureName += "?,"; } realProcedureName = realProcedureName.Substring(0, realProcedureName.Length - 1); realProcedureName += ")}"; OdbcCommand _OdbcCommand = (OdbcCommand)CreateCommand(realProcedureName, CommandType.StoredProcedure); if (parameters != null) { foreach (DBHelperParm para in parameters) { _IDbCommand.Parameters.Add(new OdbcParameter("?" + para.Key, para.Value)); } } OdbcDataAdapter _OdbcDataAdapter = new OdbcDataAdapter(_OdbcCommand); _OdbcDataAdapter.Fill(dtbRtn); return(dtbRtn); } catch (Exception ex) { throw ex; } }
public override DataTable ExecuteQuery(string cmdText, DBHelperParmCollection parameters) { DataTable dtRet = new DataTable(); AseCommand _AseCommand = (AseCommand)CreateCommand(cmdText, CommandType.Text); _AseCommand.Parameters.Clear(); if (parameters != null) { foreach (DBHelperParm para in parameters) { _AseCommand.Parameters.Add(new AseParameter(para.Key, EncodingHelper.Default2DB(para.Value, _DBEncodeing))); } } AseDataAdapter _OdbcDataAdapter = new AseDataAdapter(_AseCommand); try { ProcessDataTable(dtRet); _OdbcDataAdapter.Fill(dtRet); } catch (Exception ex) { throw ex; } return(dtRet); }
public void Save() { DBHelperParmCollection param = new DBHelperParmCollection(); param.Add(new DBHelperParm("@UserName", "UserName")); param.Add(new DBHelperParm("@Password", "Password")); StringBuilder sbSql = new StringBuilder(""); try { sbSql.Append("INSERT INTO AMP_TEST (UserName,Password) "); sbSql.Append("VALUES (?,?)"); DBHelper.ExecuteNoQuery(sbSql.ToString(), param); } catch (Exception ex) { throw ex; } }
/// <summary> /// 非查询操作 /// </summary> /// <param name="sql">sql字符串</param> /// <param name="parameters">参数集合</param> /// <returns></returns> public static int ExecuteNoQuery(string sql, DBHelperParmCollection parameters) { DBHelperBase _DBHelper = null; try { _DBHelper = CreateHelper(); return(_DBHelper.ExecuteNoQuery(sql, parameters)); } catch (Exception ex) { throw ex; } finally { if (_DBHelper != null) { _DBHelper.Close(); } } }
/// <summary> /// 执行存储过程 /// </summary> /// <param name="procedureName">过程名</param> /// <returns>返回执行正确的行数</returns> public override int ExecuteProcedureNoQuery(string procedureName, DBHelperParmCollection parameters) { int iRtn = -1; try { string realProcedureName = string.Format("{{CALL {0} (", procedureName); for (int i = 0; i < parameters.Count; i++) { realProcedureName += "?,"; } realProcedureName = realProcedureName.Substring(0, realProcedureName.Length - 1); realProcedureName += ")}"; OdbcCommand _OdbcCommand = (OdbcCommand)CreateCommand(realProcedureName, CommandType.StoredProcedure); if (parameters != null) { foreach (DBHelperParm para in parameters) { _OdbcCommand.Parameters.Add(new OdbcParameter("?" + para.Key, para.Value)); } } iRtn = _OdbcCommand.ExecuteNonQuery(); // 设置异常问题 if (iRtn == -1) { _ErrorMsg = "查无记录!"; } } catch (Exception ex) { _ErrorMsg = ex.Message; } return(iRtn); }
/// <summary> /// 返回爱影响的行数 /// </summary> /// <param name="cmdText"></param> /// <param name="parameters"></param> /// <returns></returns> public override int ExecuteNoQuery(string cmdText, DBHelperParmCollection parameters) { int effectNum; OdbcCommand _OdbcCommand = (OdbcCommand)CreateCommand(cmdText, CommandType.Text); _OdbcCommand.Parameters.Clear(); if (parameters != null) { foreach (DBHelperParm para in parameters) { _OdbcCommand.Parameters.Add(new OdbcParameter("?" + para.Key, para.Value)); } } try { effectNum = _OdbcCommand.ExecuteNonQuery(); } catch (Exception ex) { throw ex; } return(effectNum); }
public override int ExecuteNoQuery(string cmdText, DBHelperParmCollection parameters) { int effectNum; AseCommand _AseCommand = (AseCommand)CreateCommand(cmdText, CommandType.Text); _AseCommand.Parameters.Clear(); if (parameters != null) { foreach (DBHelperParm para in parameters) { _AseCommand.Parameters.Add(new AseParameter(para.Key, EncodingHelper.Default2DB(para.Value, _DBEncodeing))); } } try { effectNum = _AseCommand.ExecuteNonQuery(); } catch (Exception ex) { throw ex; } _AseCommand.Parameters.Clear(); return(effectNum); }
public override DataTable ExecuteQuery(string cmdText, DBHelperParmCollection parameters) { DataTable dtRet = new DataTable(); SqlCommand _SqlCommand = (SqlCommand)CreateCommand(cmdText, CommandType.Text); _SqlCommand.Parameters.Clear(); if (parameters != null) { foreach (DBHelperParm para in parameters) { _SqlCommand.Parameters.Add(new SqlParameter("@" + para.Key, para.Value)); } } SqlDataAdapter _SqlDataAdapter = new SqlDataAdapter(_SqlCommand); try { _SqlDataAdapter.Fill(dtRet); } catch (Exception ex) { throw ex; } return dtRet; }
public override int ExecuteNoQuery(string cmdText, DBHelperParmCollection parameters) { int effectNum; SqlCommand _SqlCommand = (SqlCommand)CreateCommand(cmdText, CommandType.Text); _SqlCommand.Parameters.Clear(); if (parameters != null) { foreach (DBHelperParm para in parameters) { _SqlCommand.Parameters.Add(new SqlParameter("@" + para.Key, para.Value)); } } try { effectNum = _SqlCommand.ExecuteNonQuery(); } catch (Exception ex) { throw ex; } return effectNum; }
public virtual DataTable ExecuteQuery(string cmdText, DBHelperParmCollection parameters) { throw new Exception("The method or operation is not implemented."); }
public override DataTable ExecuteProcedureQuery(string procedureName, DBHelperParmCollection parameters) { throw new Exception("The method or operation is not implemented."); }
public override int ExecuteNoQuery(string cmdText, DBHelperParmCollection parameters) { int effectNum; AseCommand _AseCommand = (AseCommand)CreateCommand(cmdText, CommandType.Text); _AseCommand.Parameters.Clear(); if (parameters != null) { foreach (DBHelperParm para in parameters) { _AseCommand.Parameters.Add(new AseParameter(para.Key, EncodingHelper.Default2DB(para.Value, _DBEncodeing))); } } try { effectNum = _AseCommand.ExecuteNonQuery(); } catch (Exception ex) { throw ex; } _AseCommand.Parameters.Clear(); return effectNum; }
public virtual int ExecuteProcedureNoQuery(string procedureName, DBHelperParmCollection parameters) { throw new Exception("The method or operation is not implemented."); }
public override DataTable ExecuteQuery(string cmdText, DBHelperParmCollection parameters) { DataTable dtRet = new DataTable(); AseCommand _AseCommand = (AseCommand)CreateCommand(cmdText, CommandType.Text); _AseCommand.Parameters.Clear(); if (parameters != null) { foreach (DBHelperParm para in parameters) { _AseCommand.Parameters.Add(new AseParameter(para.Key, EncodingHelper.Default2DB(para.Value, _DBEncodeing))); } } AseDataAdapter _OdbcDataAdapter = new AseDataAdapter(_AseCommand); try { ProcessDataTable(dtRet); _OdbcDataAdapter.Fill(dtRet); } catch (Exception ex) { throw ex; } return dtRet; }
public virtual DataTable ExecuteQuery(string cmdText, DBHelperParmCollection parameters) { throw new Exception("The method or operation is not implemented."); }
/// <summary> /// 执行存储过程,返回结果数据 /// </summary> /// <param name="procedureName">过程名</param> public override DataTable ExecuteProcedureQuery(string procedureName, DBHelperParmCollection parameters) { try { DataTable dtbRtn = new DataTable(); string realProcedureName = string.Format("{{CALL {0} (", procedureName); for (int i = 0; i < parameters.Count; i++) { realProcedureName += "?,"; } realProcedureName = realProcedureName.Substring(0, realProcedureName.Length - 1); realProcedureName += ")}"; OdbcCommand _OdbcCommand = (OdbcCommand)CreateCommand(realProcedureName, CommandType.StoredProcedure); if (parameters != null) { foreach (DBHelperParm para in parameters) { _IDbCommand.Parameters.Add(new OdbcParameter("?" + para.Key, para.Value)); } } OdbcDataAdapter _OdbcDataAdapter = new OdbcDataAdapter(_OdbcCommand); _OdbcDataAdapter.Fill(dtbRtn); return dtbRtn; } catch (Exception ex) { throw ex; } }
public static int ExecuteProcedureNoQuery(string procedureName, DBHelperParmCollection parameters) { throw new Exception("The method or operation is not implemented."); }
/// <summary> /// 非查询操作 /// </summary> /// <param name="sql">sql字符串</param> /// <param name="parameters">参数集合</param> /// <returns></returns> public static int ExecuteNoQuery(string sql, DBHelperParmCollection parameters) { DBHelperBase _DBHelper = null; try { _DBHelper = CreateHelper(); return _DBHelper.ExecuteNoQuery(sql, parameters); } catch (Exception ex) { throw ex; } finally { if (_DBHelper != null) _DBHelper.Close(); } }
public static DataTable ExecuteProcedureQuery(string procedureName, DBHelperParmCollection parameters) { throw new Exception("The method or operation is not implemented."); }
/// <summary> /// 执行存储过程 /// </summary> /// <param name="procedureName">过程名</param> /// <returns>返回执行正确的行数</returns> public override int ExecuteProcedureNoQuery(string procedureName, DBHelperParmCollection parameters) { int iRtn = -1; try { string realProcedureName = string.Format("{{CALL {0} (", procedureName); for (int i = 0; i < parameters.Count; i++) { realProcedureName += "?,"; } realProcedureName = realProcedureName.Substring(0, realProcedureName.Length - 1); realProcedureName += ")}"; OdbcCommand _OdbcCommand = (OdbcCommand)CreateCommand(realProcedureName, CommandType.StoredProcedure); if (parameters != null) { foreach (DBHelperParm para in parameters) { _OdbcCommand.Parameters.Add(new OdbcParameter("?" + para.Key, para.Value)); } } iRtn = _OdbcCommand.ExecuteNonQuery(); // 设置异常问题 if (iRtn == -1) _ErrorMsg = "查无记录!"; } catch (Exception ex) { _ErrorMsg = ex.Message; } return iRtn; }