private void addParameters(SqlCommand cmd, SqlDataItem sqlDataItem) { if (sqlDataItem.ParameterList == null) { return; } foreach (SqlDataParameter param in sqlDataItem.ParameterList) { cmd.Parameters.Add(new SqlParameter(buildParameterName(param.ParameterName), param.ParameterValue)); } }
public bool ExistSql_bool(SqlDataItem sqlDataItem) { DataTable dt = ExeSql_DT(sqlDataItem); if (dt != null && dt.Rows.Count > 0) { return(true); } else { return(false); } }
public static DataTable getTable(SqlDataItem item, string accountName) { try { DataSql agent = new DataSql(accountName); DataTable dt = agent.ExeSql_DT(item); agent.Close(); return(dt); } catch (Exception ex) { throw ex; } }
public string ExeSql_string(SqlDataItem sqlDataItem) { try { cmd.CommandType = Common.GetCommandType(sqlDataItem.CommandType);; cmd.CommandText = sqlDataItem.CommandText; addParameters(cmd, sqlDataItem); string result = cmd.ExecuteScalar().ToString(); return(result); } catch (Exception ex) { Close(); throw ex; } }
public int ExeSql_int(SqlDataItem sqlDataItem) { try { cmd.CommandType = Common.GetCommandType(sqlDataItem.CommandType);; cmd.CommandText = sqlDataItem.CommandText; addParameters(cmd, sqlDataItem); int t = cmd.ExecuteNonQuery(); return(t); } catch (Exception ex) { Close(); throw ex; } }
public void ExeSql_void(SqlDataItem sqlDataItem) { try { Open(); cmd.CommandType = Common.GetCommandType(sqlDataItem.CommandType); cmd.CommandText = sqlDataItem.CommandText; addParameters(cmd, sqlDataItem); cmd.ExecuteNonQuery(); } catch (Exception ex) { Close(); throw ex; } }
public static DataTable getTable(string SQLstr, string accountName) { try { SqlDataItem item = new SqlDataItem(); item.CommandText = SQLstr; DataSql agent = new DataSql(accountName); DataTable dt = agent.ExeSql_DT(item); agent.Close(); return(dt); } catch (Exception ex) { throw ex; } }
private int executeNonQuery(SqlCommand cmd, SqlDataItem sqlDataItem) { //if (cmd == null) throw new ArgumentNullException("Sql Command"); cmd.Parameters.Clear(); try { Open(); cmd.CommandText = sqlDataItem.CommandText; cmd.CommandType = Common.GetCommandType(sqlDataItem.CommandType); addParameters(cmd, sqlDataItem); return(cmd.ExecuteNonQuery()); } catch (Exception ex) { throw ex; } }
public static void ExecVoid(string sqlstr, string accountName) { DataSql agent = new DataSql(accountName); try { SqlDataItem item = new SqlDataItem(); item.CommandText = sqlstr; agent.ExeSql_void(item); agent.Close(); } catch (Exception ee) { agent.Close(); throw ee; } }
public static bool ExecSQL(SqlDataItem item, string accountName) { try { DataSql agent = new DataSql(accountName); int result = agent.ExeSql_int(item); if (result > 0) { return(true); } else { return(false); } } catch (Exception ex) { throw ex; } }
public DataTable ExeSql_DT(SqlDataItem sqlDataItem) { Open(); DataTable dt = new DataTable("data"); SqlDataAdapter ad = new SqlDataAdapter(); cmd.CommandType = Common.GetCommandType(sqlDataItem.CommandType); cmd.CommandText = sqlDataItem.CommandText; try { addParameters(cmd, sqlDataItem); ad.SelectCommand = cmd; ad.Fill(dt); ad.Dispose(); return(dt); } catch (Exception ee) { Close(); throw ee; } }
public void AppendSqlItem(SqlDataItem item) { sqlDataItemList.Add(item); }