How to execute a TableDirect command : OleDbCommand « Database ADO.net « C# / C Sharp

C# / C Sharp
1. 2D Graphics
2. Collections Data Structure
3. Components
4. Database ADO.net
5. Development Class
6. Event
7. File Stream
8. GUI Windows Form
9. Language Basics
10. Network
11. Office
12. Regular Expressions
13. Services Event
14. Thread
15. Web Services
16. Windows
17. XML
Microsoft Office Word 2007 Tutorial
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
C# / C Sharp » Database ADO.net » OleDbCommandScreenshots 
How to execute a TableDirect command


using System;
using System.Data;
using System.Data.OleDb;

class ExecuteTableDirect
{
  public static void Main()
  {
    OleDbConnection myOleDbConnection =new OleDbConnection("provider=sqloledb;server=(local)\\SQLEXPRESS;database=MyDatabase;Integrated Security=SSPI");
    OleDbCommand myOleDbCommand = myOleDbConnection.CreateCommand();

    myOleDbCommand.CommandType = CommandType.TableDirect;

    myOleDbCommand.CommandText = "Employee";

    myOleDbConnection.Open();

    OleDbDataReader myOleDbDataReader = myOleDbCommand.ExecuteReader();

    for (int count = 1; count <= 2; count++)
    {
      myOleDbDataReader.Read();
      Console.WriteLine("myOleDbDataReader[\" ID\"] = " +
        myOleDbDataReader["ID"]);
      Console.WriteLine("myOleDbDataReader[\" FirstName\"] = " +
        myOleDbDataReader["FirstName"]);
      Console.WriteLine("myOleDbDataReader[\" LastName\"] = " +
        myOleDbDataReader["LastName"]);
    }
    myOleDbDataReader.Close();
    myOleDbConnection.Close();
  }
}


           
       
Related examples in the same category
1. Execute aggregate function: sumExecute aggregate function: sum
2. Get column averageGet column average
3. Get max column valueGet max column value
4. Get count value from a select queryGet count value from a select query
5. Between certain dates
6. Delete database records through OleDbCommand and verify the results
7. Create table and populate data
8. Pass parameter to OleDbCommandPass parameter to OleDbCommand
www.java2java.com | Contact Us
Copyright 2010 - 2030 Java Source and Support. All rights reserved.
All other trademarks are property of their respective owners.