The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
|
|
No data displays in grid
Posted: 10 Jun 08 12:56 PM
|
I have a dynamically created grid that is on a managed form. I execute the script and the column captions will get added to the grid but no data displays. I added a message box to display the objRS.RecordCount and it returns a count of 8 records for the query. I run the sql statement in Query Analyzer and I get the 8 records returned with no errors. I have compared the grid properties with another grid I have that is created dynamically and I can't see anything incorrect. Using version 6.2.6..........any thoughts?? |
|
|
| |
|
Re: No data displays in grid
Posted: 10 Jun 08 2:39 PM
|
I thought of that also, but I wasn't lucky enough to get it to work. Here is the code that I am using for the grid:
strSQL = "select isnull(A4.FIRSTNAME,' ') + ' ' + isnull(A4.LASTNAME,'') + ' ' + isnull(A4.SUFFIX,'') as Attendee, " & _ "A3.customer_id, A5.account, A6.city, A6.state, A2.class_name, A2.class_code, A2.start_date, " & _ "A7.breakout_name, A7.start_date, A7.location " & _ "from tr_waiting_list A1 " & _ "left outer join tr_class A2 on (A1.tr_classid = A2.tr_classid) " & _ "left outer join c_account A3 on (A1.accountid = A3.accountid) " & _ "left outer join contact A4 on (A1.contactid = A4.contactid) " & _ "left outer join account A5 on (A1.accountid = A5.accountid) " & _ "inner join address A6 on (A5.addressid = A6.addressid) " & _ "left outer join tr_breakout A7 on (A1.tr_breakoutid = A7.tr_breakoutid) " & _ "where A1.tr_classid = 'Q6UJ9A0EFS49'"
set objConn = Application.GetNewConnection set objRS = objConn.Execute(strSQL)
dgWaitingList.SQL.Text = strSQL dgWaitingList.ReadOnly = True dgWaitingList.RowSelect = True dgWaitingList.Sortable = True dgWaitingList.Refresh
If dgWaitingList.Columns.Count > 0 then For I = 0 to dgWaitingList.Columns.Count - 1 dgWaitingList.Columns.Item(0).Delete Next End If
Set objRS = dgWaitingList.Recordset For Each fld In objRS.Fields Set col = dgWaitingList.Columns.Add(0) col.FieldName = fld.Name col.Caption = fld.Name Next
dgWaitingList.Columns.Item(0).Width = 125 dgWaitingList.Columns.Item(0).Caption = "Attendee" dgWaitingList.Columns.Item(0).Visible = true dgWaitingList.Columns.Item(1).Width = 55 dgWaitingList.Columns.Item(1).Caption = "Cust ID" dgWaitingList.Columns.Item(2).Width = 140 dgWaitingList.Columns.Item(2).Caption = "Account" dgWaitingList.Columns.Item(3).Width = 125 dgWaitingList.Columns.Item(3).Caption = "City" dgWaitingList.Columns.Item(4).Width = 125 dgWaitingList.Columns.Item(4).Caption = "State" dgWaitingList.Columns.Item(5).Width = 125 dgWaitingList.Columns.Item(5).Caption = "Class Name" dgWaitingList.Columns.Item(6).Width = 125 dgWaitingList.Columns.Item(6).Caption = "Class Code" dgWaitingList.Columns.Item(7).Width = 125 dgWaitingList.Columns.Item(7).Caption = "Class Start Date" dgWaitingList.Columns.Item(8).Width = 125 dgWaitingList.Columns.Item(8).Caption = "Breakout Name" dgWaitingList.Columns.Item(9).Width = 125 dgWaitingList.Columns.Item(9).Caption = "Breakout Start Date" dgWaitingList.Columns.Item(10).Width = 125 dgWaitingList.Columns.Item(10).Caption = "Location"
set objConn = nothing set objRS = nothing dgWaitingList.Refresh
|
|
|
|
Re: No data displays in grid
Posted: 10 Jun 08 2:48 PM
|
In your case you are retrieving the recordset so you can set the grid.Recordset property to your recordset variable rather than setting the Grid.SQL.Text property. You will not need to refresh as setting the recordset property will cause it to repaint.
I also declare my recordset variable at the form level when I use this approach. This ensures the recordset is in scope for the life of the form.
You may want to set the recordset property after you build the grid columns. This may not matter but it is worth a shot.
Lastly, why are you building the grid dynamically? The SQL seems straight forward and could be done at design time. If the attendee aliased column concatenation is the problem, simply add a calculated field and you will be able to drag it into your grid layout at design time. You may have other reasons; I am just trying to simplify for you if possible.
Timmus |
|
|
|
Re: No data displays in grid
Posted: 10 Jun 08 2:59 PM
|
The grid is one of several grids that are being displayed on a tab control on a managed form so it was just easier to code everything. The tab that this grid is displayed on is only visible if certain conditions are met. With my recorset variable I set it to equal nothing as soon as I can so the same variable can be re-used for the other grids that get populated on the tab. Thanks for the reply...........I will see if I can get the data populated. |
|
|
|
Re: No data displays in grid
Posted: 11 Jun 08 3:54 PM
|
I am able to get data to populate in the grid by using all of the existing code and changing the select statement to a simple "select * from tr_waiting_list". Once I add a where condition or a join nothing displays in the grid.
Anybody have any thoughts on this???? |
|
|
| |
|