Wednesday, August 18, 2010

VB6: How can I fill a DataGrid from a rdoResultset?

I have this code:





Dim cadena_conexion


cadena_conexion = ';DRIVER={MySQL ODBC 5.1 Driver}; SERVER='; %26amp; Form1.servidor.Text %26amp; ';; DATABASE='; %26amp; Form1.base_de_datos.Text %26amp; ';;PWD='; %26amp; Form1.password.Text %26amp; ';; UID='; %26amp; Form1.usuario.Text %26amp; ';;OPTION=3';


Set db = New rdoConnection


db.Connect = cadena_conexion


db.CursorDriver = rdUseServer


db.EstablishConnection





Dim tabla As String


Dim consulta As New rdoQuery


Dim resultados As rdoResultset





Set consulta.ActiveConnection = db


consulta.SQL = ';SELECT * from planta;';





consulta.Execute





Set resultados = consulta.OpenResultset





How can I put the results from resultados to my datagrid1 ?VB6: How can I fill a DataGrid from a rdoResultset?
Been a while since I did VB, but IIRC, you edit the properties of the datagrid to make the data source your resultset object.

No comments:

Post a Comment