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:
  1. Dim strSQL As String
  2.  
  3.   Set cn = New ADODB.Connection
  4.   cn.ConnectionString = "Data Source=spijsDB;User ID=spijs;Password=spijs;"
  5.   cn.Open
  6.   Set rs = New ADODB.Recordset
  7.   grdDatagrid.Refresh
  8.   cn.CursorLocation = adUseServer
  9.   strSQL = "Select c.celid,c.celnaam,c.celtypeid,ct.celtypenaam,c.artikelid," & _
  10.            "a.artikelnaam, TO_CHAR(a.natdroogverh),c.geblokkeerdaanvoer,c.geblokkeerdafvoer," & _
  11.            "TO_CHAR(c.fijn1kg), TO_CHAR(c.fijn2kg), TO_CHAR(c.grofkg), TO_CHAR(c.continuekg), " & _
  12.            "TO_CHAR(c.navalkg), TO_CHAR(c.soortelijkemassa)," & _
  13.            "c.wegerid,c.plccelcode, TO_CHAR(c.voorraadkg),c.lijnid,l.lijncode " & _
  14.            "From cellen c, lijnen l, celtype ct, artikelen a " & _
  15.            "where c.lijnid = l.lijnid(+) " & _
  16.            "and c.celtypeid = ct.celtypeid " & _
  17.            "and c.artikelid = a.artikelid(+)" & _
  18.            "Order by to_number(c.celid)"
  19.            
  20.   rs.Open strSQL, cn
  21.   Set grdDatagrid.DataSource = rs
  22.   grdDatagrid.Refresh
  23.   grdDatagrid.TextMatrix(0, 1) = "Nummer"
  24.   grdDatagrid.TextMatrix(0, 2) = "Naam"
  25.   grdDatagrid.TextMatrix(0, 3) = "Type"
  26.   grdDatagrid.TextMatrix(0, 4) = "Artikel"
  27.   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