C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » .NET Framework »

To access Oracle Database from VB.NET application using ADO.NET


Posted Date: 11 Oct 2004    Resource Type: Articles    Category: .NET Framework
Author: Vidya DharanMember Level: Bronze    
Rating: 1 out of 5Points: 10



Introduction

This article helps in creating a connection to Oracle Database from a VB.NET windows application using ADO.NET. After creating a connection, the article explains on how to fill a data table named PRODUCTS in oracle database into a dataset and finally bind and display PRODUCTS table in a data grid.

Steps to be followed
1. To create a new VB.NET windows application.
2. To add reference to System.Data.OracleClient.dll
3. To add a datagrid to windows form from the ToolBox
4. To create a new Oracle Connection by specifying connection string
5. To fill the dataset with PRODUCTS table in Oracle Database using Oracle Data Adapter
6. Finally to bind and display the filled dataset to the DataGrid

Code Snippet
Imports System.Data.OracleClient

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim oraConn As OracleConnection
Dim selectQuery As String
Dim da As OracleDataAdapter
Dim ds As DataSet
Dim cmd As New OracleCommand

'create new oracle connection
oraConn = New OracleConnection("user id = userName;password = passWord;data source = dataSource")

selectQuery = "SELECT * FROM PRODUCTS"
cmd.CommandType = CommandType.Text
cmd.CommandText = selectQuery
cmd.Connection = oraConn

da = New OracleDataAdapter(cmd)
ds = New DataSet

Try
'open oracle connection
oraConn.Open()

'Fill dataset with PRODUCTS table
da.Fill(ds, "PRODUCTS")

'Bind dataset to datagrid
DataGrid1.DataSource = ds
DataGrid1.Show()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub

Summary
This article gives a complete idea on how to connect and access tables in Oracle Database using ADO.NET. The same steps can be followed to access any table in Oracle Database.




Responses

Author: Sindhu Biju    18 Oct 2004Member Level: Bronze   Points : 0
The article is good but can it be more explanatory.
Suggestion:
In the Steps section please refrain from use of To. It does not sound right. Also please explain how a reference can be added. The article is targetted for newbies so please keep it elaborate.
Except for the above few problems the article is very encouraging and the code provided is self - explanatory.
It is good to know that people are really willing to spend their time for the newbies.
Great work!
Thank you
Regards,
Sindhu


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Application Center Test (ACT)
Previous Resource: Coloring Console Window and changing Title of console
Return to Discussion Resource Index
Post New Resource
Category: .NET Framework


Post resources and earn money!
 
Related Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use