On this Tutorial, I will show you a sample code on How to connect to a Oracle Database.
1. First we need to add reference to System.Data.OracleClient namespace by right-clicking your project on solution explorer then choose "Add Reference".

2. Include the following System.Data.OracleClient namespace on our code as shown below.
Imports System.Data
Imports System.Data.OracleClient
3. Then on your main function, add the code that connects to Oracle server.
Sub Main()
Dim connString As String = "server = oracleserver; uid = admin;password = password;"
'Create connection
Dim con As New OracleConnection(connString)
Try
con.ConnectionString = connString
con.Open()
Console.WriteLine("Connected to Oracle.")
Catch ex As OracleException
Console.WriteLine("Error: " & ex.ToString())
Finally
' Close Connection
con.Close()
Console.WriteLine("Connection Closed")
End Try
End Sub
For connecting to SQL, Read the following article/s.
For more VB.NET coding tips & tricks, subscribe now.
0 comments:
Post a Comment