Re: Setting active row in list control programatically
David,
I have an SQL 2008 back-end. I am receiving a database API error when executing the query that returns the row number and lot. I think it's the way we are trying to create the row number. I think rownum is used for a mysql database to create a rownumber in the query.
I can create a row number in a query I run against my database by using row_number() OVER(Order by Lotno) as rowno...That will execute successfully directly against the db but if I change my sql statement inside the xbasic function to reflect the change the rs.ToString breaks.
Here is the function
Error: error.png
David,
I have an SQL 2008 back-end. I am receiving a database API error when executing the query that returns the row number and lot. I think it's the way we are trying to create the row number. I think rownum is used for a mysql database to create a rownumber in the query.
I can create a row number in a query I run against my database by using row_number() OVER(Order by Lotno) as rowno...That will execute successfully directly against the db but if I change my sql statement inside the xbasic function to reflect the change the rs.ToString breaks.
Here is the function
Error: error.png
Code:
function lotsWithRowNumber as c (e as p) debug(1) dim cn as sql::Connection dim flag as l dim sqlStmt as c dim rs as sql::ResultSet dim args as sql::arguments flag = cn.open("::Name::SPLive") if flag then args.Set("soid",e.rv._state.__args_C_soid) args.Set("sdid",e.rv._state.__args_C_sdid) sqlStmt = "select row_number() OVER(Order by LotNo) - 1 as rowno, LotNo as ln from buyer_view where salesofficeid = :soid and subdivisionid = :sdid;" flag = cn.Execute(sqlStmt,args) if flag then rs = cn.ResultSet dim firstRow as n = rs.Data("rowno") dim dataRows as c = rs.ToString(-1,1,.f.,"|") dataRows = "RowNo|LN" + crlf() + dataRows lotsWithRowNumber = dataRows else 'there was an error - close the connection and exit cn.Close() dim msg as c msg = "Could not execute the query. Error reported was: " + cn.CallResult.text msg = js_escape(msg) dim jscmd as c jscmd = "alert('" + msg + "');" lotsWithRowNumber = jscmd exit function end if else 'there was an error - close the connection and exit dim msg as c msg = "Could not open the connection. Error reported was: " + cn.CallResult.text msg = js_escape(msg) dim jscmd as c jscmd = "alert('" + msg + "');" lotsWithRowNumber = jscmd exit function end if cn.FreeResult() cn.close() end function
Comment