VB.Net/Database ADO.net/Oracle

Материал из VB Эксперт
Перейти к: навигация, поиск

Oracle Connection String

Imports System
Imports System.Data
Imports System.Data.OracleClient
Module OracleConnect
   Sub Main()
      Dim connString As String = "server = o92; uid = vbex;password = password;"
      "Create connection
      Dim conn As New OracleConnection(connString)
      Try
         conn.Open()
         Console.WriteLine("Connection Opened")
         Console.WriteLine("Connection Properties")
         Console.WriteLine("- ConnectionString : {0}", conn.ConnectionString)
         Console.WriteLine("- ServerVersion : {0}", conn.ServerVersion)
         Console.WriteLine("- State : {0}", conn.State)
      Catch ex As OracleException
         Console.WriteLine("Error: " & ex.ToString())
      Finally
         " Close Connection
         conn.Close()
         Console.WriteLine("Connection Closed")
      End Try
   End Sub
End Module


Oracle SqlConnect

Imports System
Imports System.Data
Imports System.Data.OracleClient
Module OracleConnect
   Sub Main()
      Dim connString As String = "server = o92; uid = vbex;password = password;"
      "Create connection
      Dim conn As New OracleConnection(connString)
      Try
         conn.Open()
         Console.WriteLine("Connection Opened")
         Console.WriteLine("Connection Properties")
         Console.WriteLine("- ConnectionString : {0}", conn.ConnectionString)
         Console.WriteLine("- ServerVersion : {0}", conn.ServerVersion)
         Console.WriteLine("- State : {0}", conn.State)
      Catch ex As OracleException
         Console.WriteLine("Error: " & ex.ToString())
      Finally
         " Close Connection
         conn.Close()
         Console.WriteLine("Connection Closed")
      End Try
   End Sub
End Module