Exforsys.com
 
Home Tutorials ODP.NET
 

ODP.NET - Retrieving Multiple Rows on to the Grid

 

Pulling Information Using Table Name

Page 2 of 2

Pulling Information Using Table Name

In all of the previous examples, the SELECT statement was used to retrieve a set of rows. The SELECT statement is a good choice if you would like to retrieve only specific columns or to include some complex combinations using sub-queries, joins etc.



You can also retrieve a complete table (without using a SELECT statement) by setting the CommandType of OracleCommand to TableDirect. The following code demonstrates the use of TableDirect:


Sample Code
  1. Imports Oracle.DataAccess.Client
  2.  
  3. Public Class Form2
  4.   Private Sub btnGetEmployees_Click(ByVal sender As 
  5.     System.ObjectByVal e As System.EventArgs) Handles 
  6.     btnGetEmployees.Click
  7.     'create connection to db
  8.     Dim cn As New OracleConnection("Data Source=xe; _
  9.       User Id=scott;Password=tiger")
  10.     Try
  11.       Dim SQL As String
  12.       'build the SELECT statement
  13.  
  14.       Dim cmd As New OracleCommand("emp", cn)
  15.       cmd.CommandType = CommandType.TableDirect     
  16.       cmd.Connection.Open()
  17. ...
  18.   End Sub
  19. End Class
Copyright exforsys.com



The default CommandType is Text, which accepts any SQL statement. When we change it to TableDirect, it accepts only a table name. Another command type available is StoredProcedure. It is mainly used when you want to execute stored procedures using an OracleCommand object. (Working with PL/SQL stored procedures is covered in Chapter 5.)




First Page: ODP.NET - Retrieving Multiple Rows on to the Grid


Read Next: ODP.NET - Retrieving Typed Data



 

 

Comments



Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links

 

Subscribe via RSS


Get Daily Updates via Subscribe to Exforsys Free Training via email


Get Latest Free Training Updates delivered directly to your Inbox...

Enter your email address:


 

Subscribe to Exforsys Free Training via RSS
 

 
Partners -  Privacy and Legal Policy -  Site News -  Contact   Sitemap  

Copyright © 2000 - 2010 exforsys.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape