ReadTable() public method

Create a dynamic DataTable object from a SQL data statement. One use for this method is to create a data source for other controls that want a DataTable, like 3rd party controls.
public ReadTable ( ) : DataTable
return System.Data.DataTable
示例#1
0
文件: SQL.cs 项目: argentini/Halide
        /// <summary>
        /// Loads the results of a SQL query into a DataTable object.
        /// Uses the default connection string "Halide".
        /// </summary>
        /// <example>
        /// <code>
        /// using Argentini.Halide;
        /// ...
        /// DataTable dt = H3Sql.ReadTable("SELECT TOP 5 FROM tablename;");
        /// </code>
        /// </example>
        /// <param name="statement">SQL statement to execute.</param>
        /// <returns>DataTable object.</returns>
        public static DataTable ReadTable(string statement)
        {
            DataTable dt = new DataTable();

            using (H3Reader reader = new H3Reader(statement))
            {
                dt = reader.ReadTable();
            }

            return (dt);
        }
示例#2
0
文件: SQL.cs 项目: argentini/Halide
        /// <summary>
        /// Loads the results of a SQL query into a DataTable object.
        /// </summary>
        /// <example>
        /// <code>
        /// using Argentini.Halide;
        /// ...
        /// DataTable dt = H3Sql.ReadTable("SELECT TOP 5 FROM tablename;", "SqlServer01");
        /// </code>
        /// </example>
        /// <param name="statement">SQL statement to execute.</param>
        /// <param name="connectionStringName">Name of a connection string in the Web.config file.</param>
        /// <returns>DataTable object.</returns>
        public static DataTable ReadTable(string statement, string connectionStringName)
        {
            DataTable dt = new DataTable();

            using (H3Reader reader = new H3Reader(statement, connectionStringName))
            {
                dt = reader.ReadTable();
            }

            return (dt);
        }