Capítulo 9: Conectividad

Enlaces

Lista de soportes

Imports System.Data.Odbc

Module Program
  Sub Main()

    Dim sCon As String
    sCon = "DSN=Videoteca"

    Dim oCon As New OdbcConnection
    oCon.ConnectionString = sCon
    oCon.Open

    Dim sCmd As String
    sCmd = "SELECT * FROM soporte"

    Dim oCmd As New OdbcCommand
    oCmd.Connection = oCon
    oCmd.CommandText = sCmd

    Dim oReader As OdbcDataReader
    oReader = oCmd.ExecuteReader

    Dim sId As string
    Dim sNombre As String
    Dim sDesc As String

    While oReader.Read

      sId = oReader.GetString(0)
      sNombre = oReader.GetString(1)
      sDesc = oReader.GetString(2)

      Console.Write("(" + sId + ") ")
      Console.Write(sNombre + ": ")
      Console.WriteLine(sDesc + ".")

    End While

    oCon.Close

    Console.Write("Pulsa una tecla para continuar...")
    Console.ReadKey(True)

  End Sub
End Module