How to show less columns then selected with SQL?
Allright here's the situation,
I've made a huge SQL statement to select and Join a few tables, but I only want to show 5 of them in my grid. I'm using ADO fully in code and a MSHFlexGrid as grid. Here's my code:
VB Code:
Dim strSQL As String
Set cn = New ADODB.Connection
cn.ConnectionString = "Data Source=spijsDB;User ID=spijs;Password=spijs;"
cn.Open
Set rs = New ADODB.Recordset
grdDatagrid.Refresh
cn.CursorLocation = adUseServer
strSQL = "Select c.celid,c.celnaam,c.celtypeid,ct.celtypenaam,c.artikelid," & _
"a.artikelnaam, TO_CHAR(a.natdroogverh),c.geblokkeerdaanvoer,c.geblokkeerdafvoer," & _
"TO_CHAR(c.fijn1kg), TO_CHAR(c.fijn2kg), TO_CHAR(c.grofkg), TO_CHAR(c.continuekg), " & _
"TO_CHAR(c.navalkg), TO_CHAR(c.soortelijkemassa)," & _
"c.wegerid,c.plccelcode, TO_CHAR(c.voorraadkg),c.lijnid,l.lijncode " & _
"From cellen c, lijnen l, celtype ct, artikelen a " & _
"where c.lijnid = l.lijnid(+) " & _
"and c.celtypeid = ct.celtypeid " & _
"and c.artikelid = a.artikelid(+)" & _
"Order by to_number(c.celid)"
rs.Open strSQL, cn
Set grdDatagrid.DataSource = rs
grdDatagrid.Refresh
grdDatagrid.TextMatrix(0, 1) = "Nummer"
grdDatagrid.TextMatrix(0, 2) = "Naam"
grdDatagrid.TextMatrix(0, 3) = "Type"
grdDatagrid.TextMatrix(0, 4) = "Artikel"
grdDatagrid.TextMatrix(0, 5) = "Naam"
And the only columns I want to show are c.CellID, c.Celnaam, ct.celtypenaam, c.artikelID and a.artikelnaam
Is that possible or do I have to make a new statement with only the columns I want to show in the grid?
WiseGuy