|
-
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)
-
Apr 17th, 2002, 02:13 AM
#2
Have a look at Flexgrid.ColWidth(<column number>) = 0
You need to set the column width to 0 to hide the column(s). Note that the first column is 0 (like arrays).
Vince
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Apr 17th, 2002, 02:19 AM
#3
Even though you're hiding the column, doesn't that still imply you're retrieving the fields from the database?
Why don't you retrieve ONLY the five fields you want?
-
Apr 17th, 2002, 02:23 AM
#4
Thread Starter
Lively Member
Becouse I need the other fields to fill in some other stuff on the form.
But I'm not quite sure how I'm gonna do that so I wanted to try it this
way first. And I think this is a good solution!
Sometimes solutions are so easy that you just can't think of them 
Thanks,
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)
-
Apr 17th, 2002, 02:28 AM
#5
Then that's the way to go....
uhm...
-
Apr 17th, 2002, 02:49 AM
#6
Mendhak - its to save calling the db twice. First call would be for the list to select the second call to retrieve the data. But if you shove all the data you need into the grid and hide it you only need one call to the db reducing network connections and 'seemingly' increase the response speed 
Vince
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Apr 17th, 2002, 02:50 AM
#7
Thread Starter
Lively Member
Wow that's exactly what I thought!
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
|