Ver Mensaje Individual
  #2 (permalink)  
Antiguo 09/05/2012, 05:58
alexg88
 
Fecha de Ingreso: abril-2011
Mensajes: 1.342
Antigüedad: 13 años
Puntos: 344
Respuesta: MySQL query para un Array/Vector

Tienes que usar los métodos que hay para acceder a los resultados directamente.

Un ejemplo:


Código VB:
Ver original
  1. Dim datos(5) as String
  2.  
  3. cnString = "datasource=localhost;username=user;password=;database=database"
  4.             SQL = "SELECT * FROM tabla WHERE codigo LIKE '%" + txtBuscar.Text() + "%'"
  5.             conn = New MySqlConnection(cnString)
  6.  
  7.  
  8.         Dim command As MySqlCommand = New SqlCommand()
  9.         command.Connection = conn
  10.         command.CommandText = SQL
  11.         command.CommandType = CommandType.Text
  12.  
  13.             Try
  14.                 conn.Open()
  15.                 Dim reader As MySqlDataReader = command.ExecuteReader()
  16.  
  17.         If reader.HasRows Then
  18.             Do While reader.Read()
  19.              For i = 0 to 5
  20.               datos(i) = reader.GetString(i)
  21.              Next i
  22.             Loop
  23.         Else
  24.             Console.WriteLine("No rows returned.")
  25.         End If
  26.             Catch ex As Common.DbException
  27.                 MsgBox(ex.ToString)
  28.             Finally
  29.                 conn.Close()
  30.             End Try

Tienes más información en la página de MSDN y en la de Mysql también