ApiExamples.ExMailMerge.ExecuteDataTable C# (CSharp) Метод

ExecuteDataTable() приватный статический Метод

Utility function that creates a connection, command, executes the command and return the result in a DataTable.
private static ExecuteDataTable ( string commandText ) : DataTable
commandText string
Результат System.Data.DataTable
        private static DataTable ExecuteDataTable(string commandText)
        {
            // Open the database connection.
            string connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + 
                DatabaseDir + "Northwind.mdb";
            OleDbConnection conn = new OleDbConnection(connString);
            conn.Open();

            // Create and execute a command.
            OleDbCommand cmd = new OleDbCommand(commandText, conn);
            OleDbDataAdapter da = new OleDbDataAdapter(cmd);
            DataTable table = new DataTable();
            da.Fill(table);

            // Close the database.
            conn.Close();

            return table;
        }
        //ExEnd

Same methods

ExMailMerge::ExecuteDataTable ( ) : void