Two similar pieces of code, the first one returns a data set, the second just sends an update.
Public Shared Sub OracleConn(strServer As String, strDatabase As String)
Dim oDT As DataTable
' Create and open the connection in a using block. This
' ensures that all resources will be closed and disposed
' when the code exits.
Using oConn As New OleDb.OleDbConnection("Provider=OraOLEDB.Oracle.1;Persist Security Info=False;Data Source=dba2;User Id=****; Password=**********;")
Dim oCmd As OleDb.OleDbCommand = New OleDb.OleDbCommand()
oCmd.Connection = oConn
oCmd.CommandText = "Select * from BGGS_NEW.ENV_GLBL_CUST WHERE CUST_ID='5503'"
oCmd.CommandType = CommandType.Text
' Open the connection in a try/catch block.
' Create and execute the DataReader, writing the result
' set to the console window.
Try
oConn.Open()
Dim oDA As New OleDb.OleDbDataAdapter()
oDA.SelectCommand = oCmd
Dim oDS As New DataSet
oDA.Fill(oDS)
oDT = oDS.Tables(0)
Catch ex As OleDb.OleDbException
Console.WriteLine(ex.Message)
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
End Using
End Sub
Public Shared Sub OracleUpdate()
' Create and open the connection in a using block. This
' ensures that all resources will be closed and disposed
' when the code exits.
Using oConn As New OleDb.OleDbConnection("Provider=OraOLEDB.Oracle.1;Persist Security Info=False;Data Source=dba2;User Id=****; Password=**********;")
Dim oCmd As OleDb.OleDbCommand = New OleDb.OleDbCommand()
oCmd.Connection = oConn
oCmd.CommandText = "update BGGS_NEW.ENV_GLBL_CUST set status = 'A' WHERE CUST_ID='5503'"
oCmd.CommandType = CommandType.Text
' Open the connection in a try/catch block.
Try
oConn.Open()
oCmd.ExecuteNonQuery()
Catch ex As OleDb.OleDbException
Console.WriteLine(ex.Message)
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
End Using
End Sub