Another for MDB recorset
Another for MDB recorset
I must create two index ord on a table of a Mdb
Mdb : ecom
Table : Utenti
first = Id
second = cognome
How I must make it ?
Mdb : ecom
Table : Utenti
first = Id
second = cognome
How I must make it ?
Best Regards, Saludos
Falconi Silvio
Falconi Silvio
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
When we deal with RDMS, it is not necessary to create any index to read the table in a particular order. Careful choice of indexes on very large table improves the performance of queries.
If you want to read the columns in the order of Id the query should be "SELECT ID, COGNOME FROM UTENTI ORDER BY ID" or if you want to read in the order or cognome, say ORDERY BY COGNOME.
You can even change the order after reading the recordset.
oRs:Sort := 'ID'
or
oRs:Sort := 'COGNOME'
For all this it is not necessary to create indexes.
If you want to read the columns in the order of Id the query should be "SELECT ID, COGNOME FROM UTENTI ORDER BY ID" or if you want to read in the order or cognome, say ORDERY BY COGNOME.
You can even change the order after reading the recordset.
oRs:Sort := 'ID'
or
oRs:Sort := 'COGNOME'
For all this it is not necessary to create indexes.
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
i WANTED TO CREATE A TAB WITH TWO FOLDER
ON THE FIRST i MUST INSERT "id" AND ON THE SECOND "cOGNOME"
WHEN i CLICK ON FIRST TAB THE XBROWSE MUST CHANGE VISUALIZATION
@ oApp():oDlg:nGridBottom, nSplit+2 TABS oApp():oTab ;
OPTION nOrder SIZE oApp():oWndMain:nWidth()-50, 12 PIXEL OF oApp():oDlg ;
ITEMS ' First ', ' Last '
ACTION ( nOrder := oApp():oTab:nOption ,;
CU->(DbSetOrder(nOrder)),;
CU->(DbGoTop()) ,; oApp():oGrid:Refresh(.t.) ,;
RefreshCont(oCont, "CU") )
IMAGES "image1.bmp","image2.bmp"
HOW i CAN MAKE IT?
ON THE FIRST i MUST INSERT "id" AND ON THE SECOND "cOGNOME"
WHEN i CLICK ON FIRST TAB THE XBROWSE MUST CHANGE VISUALIZATION
@ oApp():oDlg:nGridBottom, nSplit+2 TABS oApp():oTab ;
OPTION nOrder SIZE oApp():oWndMain:nWidth()-50, 12 PIXEL OF oApp():oDlg ;
ITEMS ' First ', ' Last '
ACTION ( nOrder := oApp():oTab:nOption ,;
CU->(DbSetOrder(nOrder)),;
CU->(DbGoTop()) ,; oApp():oGrid:Refresh(.t.) ,;
RefreshCont(oCont, "CU") )
IMAGES "image1.bmp","image2.bmp"
HOW i CAN MAKE IT?
Best Regards, Saludos
Falconi Silvio
Falconi Silvio
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
ok but Ihave an variable
nOrder := 1
and then on tab I insert
ACTION ( nOrder := oApp():oTab:nOption ,;
oRs:Sort := (nOrder),;
oRs:MoveFirst())
it make error !!
I write this
@ oApp():oDlg:nGridBottom, nSplit+2 TABS oApp():oTab ;
OPTION nOrder SIZE oApp():oWndMain:nWidth()-50, 12 PIXEL OF oApp():oDlg ;
ITEMS ' First ', ' Last ' ;
ACTION ( nOrder := oApp():oTab:nOption ,;
oRs:Sort := (nOrder),;
oRs:MoveFirst() ,;
oApp():oGrid:Refresh(.t.) ,;
RefreshCont(oCont,oRs) )
nOrder := 1
and then on tab I insert
ACTION ( nOrder := oApp():oTab:nOption ,;
oRs:Sort := (nOrder),;
oRs:MoveFirst())
it make error !!
Code: Select all
Path and name: C:\work\prg\Mwopen_W\source\FSDI2006.Exe (32 bits)
Size: 1,709,568 bytes
Time from start: 0 hours 0 mins 4 secs
Error occurred at: 11-02-2008, 13:21:36
Error description: Error ADODB.Recordset/16389 E_FAIL: _SORT
Args:
[ 1] = N 2
Stack Calls
===========
Called from: win32ole.prg => TOLEAUTO:_SORT(0)
Called from: pcustomer.prg => (b)CUSTOMER(208)
Called from: TTabs.prg => TTABS:SETOPTION(712)
Called from: TTabs.prg => TTABS:LBUTTONDOWN(632)
Called from: => TWINDOW:HANDLEEVENT(0)
Called from: CONTROL.PRG => TTABS:HANDLEEVENT(0)
Called from: WINDOW.PRG => _FWH(0)
Called from: => WINRUN(0)
Called from: WINDOW.PRG => TWINDOW:ACTIVATE(0)
Called from: main.prg => TAPPLICATION:ACTIVATE(148)
Called from: main.prg => MAIN(36)
I write this
@ oApp():oDlg:nGridBottom, nSplit+2 TABS oApp():oTab ;
OPTION nOrder SIZE oApp():oWndMain:nWidth()-50, 12 PIXEL OF oApp():oDlg ;
ITEMS ' First ', ' Last ' ;
ACTION ( nOrder := oApp():oTab:nOption ,;
oRs:Sort := (nOrder),;
oRs:MoveFirst() ,;
oApp():oGrid:Refresh(.t.) ,;
RefreshCont(oCont,oRs) )
Best Regards, Saludos
Falconi Silvio
Falconi Silvio
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
You should assign column name or names delimited by commas. Not Numeric Values.
CORRECT :
oRs:Sort := 'ID'
oRs:Sort := 'COGNOME'
WRONG:
oRs:Sort := 1 or 2
Try something like this:
CORRECT :
oRs:Sort := 'ID'
oRs:Sort := 'COGNOME'
WRONG:
oRs:Sort := 1 or 2
Try something like this:
Code: Select all
ACTION ( nOrder := oApp():oTab:nOption , oRs:Sort := oRs:Fields(nOrder-1):Name, ..... )
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Now I made
@ oApp():oDlg:nGridBottom, nSplit+2 TABS oApp():oTab ;
OPTION nOrder SIZE oApp():oWndMain:nWidth()-50, 12 PIXEL OF oApp():oDlg ;
ITEMS ' First ', ' Last ' ;
ACTION ( nOrder := oApp():oTab:nOption ,;
oRs:Sort := oRs:Fields(nOrder-1):Name,;
oRs:MoveFirst() ,;
oApp():oGrid:Refresh(.t.) ,;
RefreshCont(oCont,oRs) )
Application
===========
Path and name: C:\work\prg\Mwopen_W\source\FSDI2006.Exe (32 bits)
Size: 1,789,952 bytes
Time from start: 0 hours 0 mins 3 secs
Error occurred at: 11-02-2008, 14:00:09
Error description: Error ADODB.Recordset/16389 E_FAIL: _SORT
Args:
[ 1] = C UserID
Stack Calls
===========
Called from: win32ole.prg => TOLEAUTO:_SORT(0)
Called from: pcustomer.prg => (b)CUSTOMER(206)
Called from: TTabs.prg => TTABS:SETOPTION(712)
Called from: TTabs.prg => TTABS:LBUTTONDOWN(632)
Called from: => TWINDOW:HANDLEEVENT(0)
Called from: CONTROL.PRG => TTABS:HANDLEEVENT(0)
Called from: WINDOW.PRG => _FWH(0)
Called from: => WINRUN(0)
Called from: WINDOW.PRG => TWINDOW:ACTIVATE(0)
Called from: main.prg => TAPPLICATION:ACTIVATE(149)
Called from: main.prg => MAIN(37)
i'm afraid thart oRs:Sort take only filed name and not field number
any idea ?
@ oApp():oDlg:nGridBottom, nSplit+2 TABS oApp():oTab ;
OPTION nOrder SIZE oApp():oWndMain:nWidth()-50, 12 PIXEL OF oApp():oDlg ;
ITEMS ' First ', ' Last ' ;
ACTION ( nOrder := oApp():oTab:nOption ,;
oRs:Sort := oRs:Fields(nOrder-1):Name,;
oRs:MoveFirst() ,;
oApp():oGrid:Refresh(.t.) ,;
RefreshCont(oCont,oRs) )
Application
===========
Path and name: C:\work\prg\Mwopen_W\source\FSDI2006.Exe (32 bits)
Size: 1,789,952 bytes
Time from start: 0 hours 0 mins 3 secs
Error occurred at: 11-02-2008, 14:00:09
Error description: Error ADODB.Recordset/16389 E_FAIL: _SORT
Args:
[ 1] = C UserID
Stack Calls
===========
Called from: win32ole.prg => TOLEAUTO:_SORT(0)
Called from: pcustomer.prg => (b)CUSTOMER(206)
Called from: TTabs.prg => TTABS:SETOPTION(712)
Called from: TTabs.prg => TTABS:LBUTTONDOWN(632)
Called from: => TWINDOW:HANDLEEVENT(0)
Called from: CONTROL.PRG => TTABS:HANDLEEVENT(0)
Called from: WINDOW.PRG => _FWH(0)
Called from: => WINRUN(0)
Called from: WINDOW.PRG => TWINDOW:ACTIVATE(0)
Called from: main.prg => TAPPLICATION:ACTIVATE(149)
Called from: main.prg => MAIN(37)
i'm afraid thart oRs:Sort take only filed name and not field number
any idea ?
Best Regards, Saludos
Falconi Silvio
Falconi Silvio
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
and
@ oApp():oDlg:nGridBottom, nSplit+2 TABS oApp():oTab ;
OPTION nOrder SIZE oApp():oWndMain:nWidth()-50, 12 PIXEL OF oApp():oDlg ;
ITEMS ' First ', ' Last ' ;
ACTION ( nOrder := oApp():oTab:nOption ,;
if( norder=1, oRs:Sort( "ID" ),oRs:Sort( "Cognome" )),;
oRs:MoveFirst() ,;
oApp():oGrid:Refresh(.t.) ,;
RefreshCont(oCont,oRs) )
but it not run !!
@ oApp():oDlg:nGridBottom, nSplit+2 TABS oApp():oTab ;
OPTION nOrder SIZE oApp():oWndMain:nWidth()-50, 12 PIXEL OF oApp():oDlg ;
ITEMS ' First ', ' Last ' ;
ACTION ( nOrder := oApp():oTab:nOption ,;
if( norder=1, oRs:Sort( "ID" ),oRs:Sort( "Cognome" )),;
oRs:MoveFirst() ,;
oApp():oGrid:Refresh(.t.) ,;
RefreshCont(oCont,oRs) )
but it not run !!
Best Regards, Saludos
Falconi Silvio
Falconi Silvio
I try also this but not run
@ oApp():oDlg:nGridBottom, nSplit+2 TABS oApp():oTab ;
OPTION nOrder SIZE oApp():oWndMain:nWidth()-50, 12 PIXEL OF oApp():oDlg ;
ITEMS ' First ', ' Last ' ;
ACTION ( nOrder := oApp():oTab:nOption ,;
if( norder=1, oRs:Sort := 'ID' ,oRs:Sort := 'COGNOME' ),;
oRs:MoveFirst() ,;
oApp():oGrid:Refresh(.t.) ,;
RefreshCont(oCont,oRs) )
@ oApp():oDlg:nGridBottom, nSplit+2 TABS oApp():oTab ;
OPTION nOrder SIZE oApp():oWndMain:nWidth()-50, 12 PIXEL OF oApp():oDlg ;
ITEMS ' First ', ' Last ' ;
ACTION ( nOrder := oApp():oTab:nOption ,;
if( norder=1, oRs:Sort := 'ID' ,oRs:Sort := 'COGNOME' ),;
oRs:MoveFirst() ,;
oApp():oGrid:Refresh(.t.) ,;
RefreshCont(oCont,oRs) )
Best Regards, Saludos
Falconi Silvio
Falconi Silvio
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
- Rick Lipkin
- Posts: 2397
- Joined: Fri Oct 07, 2005 1:50 pm
- Location: Columbia, South Carolina USA
question ... on a related note .. consider this query :
Select lname,fname from Customer order by lname
...
...
lets say I want to re-order my existing recordset created by the above query .. are you saying I can oRs:Sort := 'fname' to reorder ?? or do I need to re-create the query with order by fname ?
Rick Lipkin
Select lname,fname from Customer order by lname
...
...
lets say I want to re-order my existing recordset created by the above query .. are you saying I can oRs:Sort := 'fname' to reorder ?? or do I need to re-create the query with order by fname ?
Rick Lipkin
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Mr Rick Liptin
>
ets say I want to re-order my existing recordset created by the above query .. are you saying I can oRs:Sort := 'fname' to reorder ??
>
Yes.
>
or do I need to re-create the query with order by fname ?
>
No need at all.
If we do, that will increase response time and unnecessary burden on the server and also the network traffic.
Actually, it is a good idea not to request an ordered set from the server, but to do the sorting on the client. When we request an ordered set, the sever has to do an additional work of sorting, creating temporary tables and so on. We should place the least strain on the server and and the network bandwidth.
>
ets say I want to re-order my existing recordset created by the above query .. are you saying I can oRs:Sort := 'fname' to reorder ??
>
Yes.
>
or do I need to re-create the query with order by fname ?
>
No need at all.
If we do, that will increase response time and unnecessary burden on the server and also the network traffic.
Actually, it is a good idea not to request an ordered set from the server, but to do the sorting on the client. When we request an ordered set, the sever has to do an additional work of sorting, creating temporary tables and so on. We should place the least strain on the server and and the network bandwidth.
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India