.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> .NET Framework >> Post New QuestionBookmark and Share Subscribe to Forum

Oracle Database connection Program in Vb.Net

Posted By: Sushil     Posted Date: February 09, 2010    Points:2   Category :.NET Framework
I want sample ADD,UPDATE,DELETE,SEARCH Record Program in Vb.Net with
BackEnd -Oracle 10g
what is the Server name for Oracle Coonection Strig?
Plz Help Me.

Responses
Author: Sagar Pardeshi             
Posted Date: February 09, 2010     Points: 5   

Follow the steps:
Importing the Namespaces
Imports System
Imports Oracle.DataAccess.Client

###Step 1 The first step is to create an OracleConnection object to connect to the Oracle database and then open the connection.

Dim myOracleConnection As New OracleConnection( _
"User Id=store;Password=store;Data Source=ORCL")
myOracleConnection.Open()

###Step2 The second step is to create an OracleTransaction object and start the transaction by calling the BeginTransaction() method of the OracleConnection object.

Dim myOracleTransaction As OracleTransaction = _
myOracleConnection.BeginTransaction()

###Step3 The third step is to create an OracleCommand object to store a SQL statement.

Dim myOracleCommand As OracleCommand =
myOracleConnection.CreateCommand

###Step 4 The fourth step is to set the CommandText property of the OracleCommand object to the DELETE statement that deletes a row from the table.

myOracleCommand.CommandText = _
"delete from table where id = ' " & txtID.txt & "'"

Step 5

The fifth step is to run the DELETE statement using the ExecuteNonQuery() method of the OracleCommand object.

Dim Delete = MessageBox.Show("Are You Sure to Delete", "Query", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If (Delete = vbYes) Then
myOracleCommand.ExecuteNonQuery()
MessageBox.Show("Record Deleted successfully!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If

Step 6

The eighth step is to commit the transaction in the database using the Commit() method of the OracleTransaction object.
In VB.NET:


myOracleTransaction.Commit()

Step 7

The ninth step is to close the OracleConnection object using the Close() method.

myOracleConnection.Close()



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend