From: Roger Lawton on
Geoff:

Ok, I will have to look into using CTEs.

Thanks

Roger Lawton
Product Manager
SOMAX, Inc.

"Geoff Schaller" <geoffx(a)softxwareobjectives.com.au> wrote in message
news:gGaWn.960$vD2.500(a)news-server.bigpond.net.au...
> Roger,
>
> That wasn't his issue. He renamed the column in the browser, that is all.
> Now he needs to detect the column clicked so that he can reissue the
> orderby. The orderby will still be in the original column name. But you
> can also easily alias any column and using CTE you can now order by the
> aliased name if you want to.
>
> Geoff
>
>

From: BillT on
Geoff,
I am struggling to get my head around some of this SQL stuff! Are you
(or anybody else) able to give me some specific help, please?

I eventually want to join two tables, but let's keep it simply to one
table initially.
I have defined an SQL Server using the SQL Editor - namely SQLProduct
- in which I declare the ODBC DSN as "Galtech2" which refers to the
Galtechbd.mdb database containing the Product table.

From this server definition, I instantiate an object, oProductSQL.
Can I do something like -
oStmt := SQLStatement{"Select * from oProductSQL WHERE
oProductSQL.CategoryID = 22", oConn}
oSel := oStmt:Execute()


OR do I have to bypass the SQLEditor and do something like I have used
in ASP code for the web site:-

'---------------------------------------
'connect to the database
'---------------------------------------
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open "Galtech2"

'------------------------------------------
'get selected Products
'------------------------------------------
ProductList = "SELECT * FROM tblProduct WHERE ProductID < 100 ORDER BY
ProductName"
Set oRsProduct = oConn.execute(ProductList)


If this latter, what should the table name be in the Select - Product
as in the .mdb database, SQLProduct as defined via the editor, or
oProductSQL as instantiated above, or something else?

Many thanks in advance,
Bill

From: Johan Nel on
Hi Bill,

Sorry not on my VO laptop, but here goes:

oConn := SqlConnection{"GalTech2"}
oSelect := SqlSelect{;
"SELECT * FROM tblProduct " + ;
"WHERE ProductID < 100 " + ;
"ORDER BY ProductName", oConn}

In general I kept away from the SQL Editor or any hardcoded classes.

Regards,

Johan Nel
Pretoria, South Africa.

On Jun 30, 5:13 am, BillT <wtill...(a)hotmail.com> wrote:
> Geoff,
> I am struggling to get my head around some of this SQL stuff! Are you
> (or anybody else) able to give me some specific help, please?
>
> I eventually want to join two tables, but let's keep it simply to one
> table initially.
> I have defined an SQL Server using the SQL Editor - namely SQLProduct
> - in which I declare the ODBC DSN as "Galtech2" which refers to the
> Galtechbd.mdb database containing the Product table.
>
> From this server definition, I instantiate an object, oProductSQL.
> Can I do something like -
> oStmt := SQLStatement{"Select * from oProductSQL WHERE
> oProductSQL.CategoryID = 22", oConn}
> oSel := oStmt:Execute()
>
> OR do I have to bypass the SQLEditor and do something like I have used
> in ASP code for the web site:-
>
> '---------------------------------------
> 'connect to the database
> '---------------------------------------
> Set oConn = Server.CreateObject("ADODB.Connection")
> oConn.Open "Galtech2"
>
> '------------------------------------------
> 'get selected Products
> '------------------------------------------
> ProductList = "SELECT * FROM tblProduct WHERE ProductID < 100 ORDER BY
> ProductName"
> Set oRsProduct = oConn.execute(ProductList)
>
> If this latter, what should the table name be in the Select - Product
> as in the .mdb database, SQLProduct as defined via the editor, or
> oProductSQL as instantiated above, or something else?
>
> Many thanks in advance,
> Bill

From: Geoff Schaller on
They are veeeeeeery powerful.

But you'll notice we solved Bill's issue a slightly different way.



"Roger Lawton" <nsproger(a)nspsomax.com> wrote in message
news:i0cr9k$fjv$2(a)speranza.aioe.org:

> Geoff:
>
> Ok, I will have to look into using CTEs.
>
> Thanks
>
> Roger Lawton
> Product Manager
> SOMAX, Inc.
>
> "Geoff Schaller" <geoffx(a)softxwareobjectives.com.au> wrote in message
> news:gGaWn.960$vD2.500(a)news-server.bigpond.net.au...
>
> > Roger,
> >
> > That wasn't his issue. He renamed the column in the browser, that is all.
> > Now he needs to detect the column clicked so that he can reissue the
> > orderby. The orderby will still be in the original column name. But you
> > can also easily alias any column and using CTE you can now order by the
> > aliased name if you want to.
> >
> > Geoff
> >
> >

From: BillT on
Johan,
I have done that, but am still having problems! I have created a new
DW that is called from a PB on an existing window. The new DW has only
a FixedText control and a bBrowser.
The code on the PB is:-

METHOD TestSQLPB( ) CLASS Product2List

self:oConn := SQLConnection{"GalTech2"} //Johan's code
self:oSelect := SQLSelect{;
"SELECT * FROM tblProduct" + ;
"WHERE ProductID < 100 " + ;
"ORDER BY ProductName", self:oConn}

self:oWin := TestDW{self}
self:oWin:Use(self:oSelect) // assign the SQL selection to the
window
self:oWin:show()
RETURN nil
-------------------------------------------
Then in the PostInit of the DW I have:-

method PostInit(oWindow,iCtlID,oServer,uExtra) class TestDW
//Put your PostInit additions here
LOCAL oColumn as bDataColumn

self:oDCbBrowser1:Use(self:server, {})

//Column for ProductID
oColumn := bDataColumn{oDCbBrowser1, self:server, "ProductId",
#FIELD}
oColumn:Width := 30
oColumn:Caption := "ID"
self:oDCbBrowser1:AddColumn( oColumn )
self:oDCbBrowser1:OpenColumn(oColumn )

return nil
-------------------
The PostInit code is identical to the first few lines of that which I
already use successfully on the Parent Window.
Now I am back to getting a similar error to that I was getting a week
or two ago. The oColumn := bDataColumn{oDCbBrowser1 etc} is being
rejected at runtime as Argument Number 1, Type: OBJECT, Argument:
6, Function: SEND, Subsystem: BASE, Error Code:33 (DATA TYPE ERROR)

Also I tried a InfoBox to inspect the reccount for the oSelect and it
showed 0.

What have I stuffed up now??
Thanks,
Bill