|
-
Apr 17th, 2002, 01:59 AM
#1
Thread Starter
Lively Member
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
I stuck my head out of the window and got arrested for mooning!
This Post is sponsored by my PC: PIII900, 512MBDimm/133, Seagate 40GB/7200 ATA100, LiteOn 12x DVD, Lite-On 32x12x40 CDrw, Elsa Geforce2 Ultra 64MB incl tv-out, SoundBlaster Live 1024, Ilyama A702HT Vision Master Pro410 17".
O/S: Windows XP Professional (dutch)
Internet: Cable (1Mbit connection)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|