Alpha Video Training
Results 1 to 13 of 13

Thread: Problem with RowExpander issue - showing it when a field has a link in another grid`

  1. #1
    Member
    Real Name
    Roelof
    Join Date
    Jul 2008
    Location
    Seattle, WA
    Posts
    763

    Default Problem with RowExpander issue - showing it when a field has a link in another grid`

    I have asked this before but did not get it to work.

    One table, called project has a field (numeric) called MainSR
    Another table, called help (on another server) has a field called (character) Assettag

    So I want to show the Row Expander when the field in the mainSR and the Assettag field are the same.

    I have created this:
    debug(1)
    ShowRowExpanderIcon = .t.
    '
    DIM cn as SQL::Connection
    dim flagResult as l
    cn.open("::Name::Help")
    flagResult = cn.open("::Name::Help")
    if flagResult = .f. then
    ui_msg_box("Error","Could not connect to database. Error reported was: " + crlf() + cn.CallResult.text)
    end
    end if

    dim sqltxt as c
    dim args as sql::arguments
    sqltxt=<<%txt%
    SELECT count(*) from help where assettag =args1
    %txt%

    args.set("args1",convert_type(e.rowData.data("MainSR"),"N"))
    e.conn.execute(sqltxt,args)
    dim count as n

    count = e.cn.resultset.data(1)

    if count = 0 then
    ShowRowExpanderIcon = .f.
    else
    ShowRowExpanderIcon = .t.
    end if

    cn.Close()

    It throws an error on :count = e.cn.resultset.data(1) and this is the error: Property not found e.cn.subelement not found

    Could someone point me in the right direction to make this work?

    Thanks
    Roelof

  2. #2
    "Certified" Alphaholic
    Real Name
    Frank Bicknell
    Join Date
    Feb 2010
    Location
    39.1915° N, 84.4348° W
    Posts
    2,467

    Default Re: Problem with RowExpander issue - showing it when a field has a link in another gr

    I don't think you want your table and connection to have the same name. You are opening your connection twice. Also e.conn.execute(sqltxt,args) should be cn.execute(sqltxt,args), count = e.cn.resultset.data(1) should be count = cn.resultset.data(1)
    ui_msg_box() does not work on the web.
    Win 10 64 Development, Win 7 64 WAS 11-1, 2, Win 10 64 AA-1,2, MySql, dbForge Studio The Best MySQL GUI Tool IMHO. http://www.devart.com/dbforge/mysql/studio/

  3. #3
    Member
    Real Name
    Roelof
    Join Date
    Jul 2008
    Location
    Seattle, WA
    Posts
    763

    Default Re: Problem with RowExpander issue - showing it when a field has a link in another gr

    I have changed the Xbasic function to:
    debug(1)
    ShowRowExpanderIcon = .t.
    '
    DIM cn as SQL::Connection
    dim flagResult as l
    cn.open("::Name::Help")


    dim sqltxt as c
    dim args as sql::arguments
    sqltxt=<<%txt%
    SELECT count(*) from helprequest where assettag =args1
    %txt%

    args.set("args1",convert_type(e.rowData.data("MainSR"),"N"))
    cn.execute(sqltxt,args)
    dim count as n

    count = cn.resultset.data(1)

    if count = 0 then
    ShowRowExpanderIcon = .f.
    else
    ShowRowExpanderIcon = .t.
    end if

    cn.Close()

    But I still get the error at this line count = cn.resultset.data(1), and the error is :Function sequence error, while getting latest result set.'cn.resultset subelement not found.

    I really wont this to work. I cannot figure this out.

  4. #4
    "Certified" Alphaholic Lance Gurd's Avatar
    Real Name
    Lance Gurd
    Join Date
    Jun 2005
    Location
    Southampton, UK
    Posts
    1,437

    Default Re: Problem with RowExpander issue - showing it when a field has a link in another gr

    Is 'Help' the name of your connection string or as you say in your opening paragraph
    Another table, called help (on another server)
    ?

    If it is a table in a database you need to use a named connection string to the database then in the select statement refer to the table you want to get the data from as in
    Code:
    dim conn as SQL::Connection
    
    conn.open("::name::alphasports")
    where alphasports is a saved named connection string, not the name of an alternate database.

  5. #5
    Member
    Real Name
    Roelof
    Join Date
    Jul 2008
    Location
    Seattle, WA
    Posts
    763

    Default Re: Problem with RowExpander issue - showing it when a field has a link in another gr

    Quote Originally Posted by Lance Gurd View Post
    Is 'Help' the name of your connection string or as you say in your opening paragraph ?

    Help is the name of the connection string to another sqlserver table

    If it is a table in a database you need to use a named connection string to the database then in the select statement refer to the table you want to get the data from as in
    Code:
    dim conn as SQL::Connection
    
    conn.open("::name::alphasports")
    where alphasports is a saved named connection string, not the name of an alternate database.
    Help is the name of the connection string and this is the connection string : {A5API='SQLServer',A5DBVersion=2008,Server='(local)',A5ANSINullPadWarn=Default,Trusted_connection=yes,Database='Help'}

    Then in the help database there is a table called helprequest

    If this does not work I will need to buy a help request from Alpha5. This needs to work I don't know why this does not work.

  6. #6
    Member
    Real Name
    Michael Smith
    Join Date
    Mar 2010
    Posts
    45

    Default Re: Problem with RowExpander issue - showing it when a field has a link in another gr

    Instead of using arguments did you try write to out the sql string?

    sqltxt= "SELECT count(*) from helprequest where assettag = " + convert_type(e.rowData.data("MainSR"),"N"))
    cn.execute(sqltxt)

    Then you can use debug to see the string make sure it is written correctly, try it in your database query builder to see if it is returning the correct result.

  7. #7
    Member
    Real Name
    Roelof
    Join Date
    Jul 2008
    Location
    Seattle, WA
    Posts
    763

    Default Re: Problem with RowExpander issue - showing it when a field has a link in another gr

    Well I got it to work, thanks to all of your help. And I have learned a lot.

    dim cn as sql::Connection
    dim sqlstatement as c
    dim args as sql::Arguments
    dim rs as sql::resultset
    dim x as c
    dim cs as c


    sqlstatement = "SELECT count(*) from helprequest where assettag = :args"
    cn.open("::Name::Help")
    if cn.open(cs)
    args.add("args", e.rowData.data("MainSR"))
    cn.Execute(sqlstatement,args)
    if cn.execute(sqlstatement,args)
    rs = cn.ResultSet
    dim count as n
    count - 0
    count = cn.resultset.data(1)

    if count = 0 then
    ShowRowExpanderIcon = .f.
    else
    ShowRowExpanderIcon = .t.
    end if

    else
    x = "Execute failed: " + cn.callResult
    end if
    else
    'Connection failed. Display message from cn.CallResult
    x = "Connection failed: " + cn.CallResult
    end if
    if cn.IsOpen
    cn.Close()
    end if

    I do still have one question left, how can use the count(*) in my grid? Do I have to use it in the SQL statement like count(*) as <variable>, and than use that variable in the grid?

  8. #8
    "Certified" Alphaholic
    Real Name
    Frank Bicknell
    Join Date
    Feb 2010
    Location
    39.1915° N, 84.4348° W
    Posts
    2,467

    Default Re: Problem with RowExpander issue - showing it when a field has a link in another gr

    Quote Originally Posted by Atta View Post
    Well I got it to work, thanks to all of your help. And I have learned a lot.

    I do still have one question left, how can use the count(*) in my grid? Do I have to use it in the SQL statement like count(*) as <variable>, and than use that variable in the grid?


    yes
    Win 10 64 Development, Win 7 64 WAS 11-1, 2, Win 10 64 AA-1,2, MySql, dbForge Studio The Best MySQL GUI Tool IMHO. http://www.devart.com/dbforge/mysql/studio/

  9. #9
    Member
    Real Name
    Roelof
    Join Date
    Jul 2008
    Location
    Seattle, WA
    Posts
    763

    Default Re: Problem with RowExpander issue - showing it when a field has a link in another gr

    OK I understand that but I can not see that variable in available fields so where do I put that?

  10. #10
    "Certified" Alphaholic
    Real Name
    Frank Bicknell
    Join Date
    Feb 2010
    Location
    39.1915° N, 84.4348° W
    Posts
    2,467

    Default Re: Problem with RowExpander issue - showing it when a field has a link in another gr

    dim lnCount as I

    Select count(*) as nCount or Kount
    lnCount = cn.resultset.data(1)

    You really should be careful using 'reserverd' words for variables like count. I am not sure exactly what all of the reserved words are but I try to avoid naming variables the same as any that can be used in code. There are many naming conventions some were discussed on this board. I use what I learned from VFP things like lcVariableName for local character, lnVariableName for local numeric, etc.This helps assure that you are not using reserved words.
    Win 10 64 Development, Win 7 64 WAS 11-1, 2, Win 10 64 AA-1,2, MySql, dbForge Studio The Best MySQL GUI Tool IMHO. http://www.devart.com/dbforge/mysql/studio/

  11. #11
    Member
    Real Name
    Roelof
    Join Date
    Jul 2008
    Location
    Seattle, WA
    Posts
    763

    Default Re: Problem with RowExpander issue - showing it when a field has a link in another gr

    Thank you for mentioning that, I keep doing it and then can't figure out why I have issues in my code.

    But how do I use that variable in a grid.?

    Thanks again.

  12. #12
    "Certified" Alphaholic
    Real Name
    Frank Bicknell
    Join Date
    Feb 2010
    Location
    39.1915° N, 84.4348° W
    Posts
    2,467

    Default Re: Problem with RowExpander issue - showing it when a field has a link in another gr

    If you want the count to be available as a field in the grid you will need to create the sql select statement in the query of the grid.
    Win 10 64 Development, Win 7 64 WAS 11-1, 2, Win 10 64 AA-1,2, MySql, dbForge Studio The Best MySQL GUI Tool IMHO. http://www.devart.com/dbforge/mysql/studio/

  13. #13
    Member
    Real Name
    Wayne
    Join Date
    Aug 2009
    Posts
    129

    Default Re: Problem with RowExpander issue - showing it when a field has a link in another gr

    I use Kount....... Looks like I dont know how to spell in my code, but avoids the reserved word.

Similar Threads

  1. Row Expander Problem Showing Linked Grid with Image Ref Field
    By jkletrovets in forum Application Server Version 10 - Web/Browser Applications
    Replies: 5
    Last Post: 05-11-2010, 01:14 AM
  2. Link dialog to grid issue
    By Peter.Greulich in forum Application Server Version 9 - Web/Browser Applications
    Replies: 3
    Last Post: 08-27-2009, 05:02 PM
  3. Grid link simple problem
    By vinyltap in forum Application Server Version 9 - Web/Browser Applications
    Replies: 2
    Last Post: 07-31-2008, 01:45 PM
  4. Link to grid with filter problem
    By Flommer in forum Application Server Version 8
    Replies: 0
    Last Post: 11-21-2007, 05:07 PM
  5. Add field to table not showing in Grid builder
    By Peter.Greulich in forum Web Application Server v7
    Replies: 6
    Last Post: 01-02-2006, 12:40 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •