Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
titleVisual Basic example source
themeEmacs
languagevb
Sub Main() 
    Dim cn As Odbc.OdbcConnection
    Dim cmd As Odbc.OdbcCommand
    Dim dr As Odbc.OdbcDataReader
 
    cn = New Odbc.OdbcConnection
    cmd = New Odbc.OdbcCommand
 
    cn.ConnectionString = “ODBC connection string”
 
    Try
        cn.Open()
        Console.WriteLine("Successfully connected.")
        cmd.Connection = cn
 
        cmd.CommandText = "SELECT TO_CHAR(SYSDATE,'YYYY-MM-DD HH:MI:SS')FROM DUAL"
 
        dr = cmd.ExecuteReader()
        While (dr.Read())
            Console.WriteLine(dr.GetString(0))
        End While
    Catch ex As Odbc.OdbcException
        Console.WriteLine("Error in the connection" + ex.Message)
    End Try
 
    Console.ReadLine()
End Sub

...