Exemplo n.º 1
0
        /// <summary>
        /// Execute the query with parameters and getting the result set
        /// </summary>
        /// <param name="query">Query to execute</param>
        /// <param name="parameters">The stored procedure's params, the dictionary's Key and the stored procedure's parameter must have the same name</param>
        /// <returns>The result of the stored procedure's SELECT statement</returns>
        public static DataTable getDataTableFromQuery(string query, Dictionary <string, object> parameters)
        {
            var cmd = ConnectionTools._createConnection(query, CommandType.Text);

            if (parameters != null)
            {
                cmd = AddParameters(cmd, parameters);
            }
            return(ConnectionTools._getDataTable(cmd));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Call a Stored procedure with parameters, specifying the connection string and getting the result set
        /// </summary>
        /// <param name="storedProcedure">Stored procedure name</param>
        /// <param name="parameters">The stored procedure's params, the dictionary's Key and the stored procedure's parameter must have the same name</param>
        /// <param name="connStr">Connection string to use</param>
        /// <returns>The result of the stored procedure's SELECT statement</returns>
        public static DataTable getDataTable(string storedProcedure, Dictionary <string, object> parameters, string connStr)
        {
            var cmd = ConnectionTools._createConnection(storedProcedure, CommandType.StoredProcedure, connStr);

            if (parameters != null)
            {
                cmd = AddParameters(cmd, parameters);
            }
            return(ConnectionTools._getDataTable(cmd));
        }
Exemplo n.º 3
0
 /// <summary>
 /// Execute the query with no parameters, specifying the connection string and getting the result set
 /// </summary>
 /// <param name="query">Query to execute</param>
 /// <param name="connStr">Connection string to use</param>
 /// <returns>The result of the stored procedure's SELECT statement</returns>
 public static DataTable getDataTableFromQuery(string query, string connStr)
 {
     return(ConnectionTools._getDataTable(ConnectionTools._createConnection(query, CommandType.Text, connStr)));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Call a Stored procedure with no parameters, specifying the connection string and getting the result set
 /// </summary>
 /// <param name="storedProcedure">Stored procedure name</param>
 /// <param name="connStr">Connection string to use</param>
 /// <returns>The result of the stored procedure's SELECT statement</returns>
 public static DataTable getDataTable(string storedProcedure, string connStr)
 {
     return(ConnectionTools._getDataTable(ConnectionTools._createConnection(storedProcedure, CommandType.StoredProcedure, connStr)));
 }