Press "Enter" to skip to content

Executing Oracle Command in VB.Net

Running Oracle commands in with Tns less  connection string.

Imports required for the following procedure are:
Imports System.Data
Imports System.Data.OleDb

Pass the oracle command as parameter to following procedure.

Public Sub execute_oracledb_command(ByVal cmdstring As String)
        Dim oraconnection As OleDbConnection
        Dim oracommand As OleDbCommand

        dim srcconnect as string = “Provider=OraOLEDB.Oracle;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=YourHost)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=YourService)));User Id=YourUser;Password=YourPsw;”

        oraconnection = New OleDbConnection(srcconnect)
            ‘opening the connection
            oracommand = New OleDbCommand(cmdstring, oraconnection)
        Catch ee As Exception
        End Try
End Sub

One Comment

  1. Khalid Qureshi Khalid Qureshi January 26, 2013

    This tns less connection string is good… works fine with .net 2005 to 2010…

Comments are closed.