Hello,
I am new to pulling data into VB and using DataGridViews.. ... so this
might be a dumb question but I can not seem to understand how to make this
work.
What I need acomplished:
Exec a select statement and out put the results to a DataGridView. The
columns must be created on the fly as the query may return different fields.
A small example I got to work to a List box. If you could convert this to a
DGV for me it would be great ....
Col1 - Full Name
Col2 - Address
oSQLcmd.Connect ion = oSQLconn
oSQLcmd.Command Type = CommandType.Tex t
oSQLcmd.Command Text = "SELECT FullNAME, Address FROM t_dssemp"
strSQLopen = OpenSQLConn() ' Open Connection
If oSQLconn.State = ConnectionState .Open Then
oSQLdr = oSQLcmd.Execute Reader() 'executing the command and
assigning it to connection
While oSQLdr.Read()
ListBox1.Items. Add(oSQLdr.Item ("FullName") & " " &
oSQLdr.Item("Ad dress"))
End While
End If
oSQLdr.Close()
Thank you very much
Marcelo
I am new to pulling data into VB and using DataGridViews.. ... so this
might be a dumb question but I can not seem to understand how to make this
work.
What I need acomplished:
Exec a select statement and out put the results to a DataGridView. The
columns must be created on the fly as the query may return different fields.
A small example I got to work to a List box. If you could convert this to a
DGV for me it would be great ....
Col1 - Full Name
Col2 - Address
oSQLcmd.Connect ion = oSQLconn
oSQLcmd.Command Type = CommandType.Tex t
oSQLcmd.Command Text = "SELECT FullNAME, Address FROM t_dssemp"
strSQLopen = OpenSQLConn() ' Open Connection
If oSQLconn.State = ConnectionState .Open Then
oSQLdr = oSQLcmd.Execute Reader() 'executing the command and
assigning it to connection
While oSQLdr.Read()
ListBox1.Items. Add(oSQLdr.Item ("FullName") & " " &
oSQLdr.Item("Ad dress"))
End While
End If
oSQLdr.Close()
Thank you very much
Marcelo
Comment