Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DTC Listbox problem 1

Status
Not open for further replies.

lehel

Programmer
Jun 18, 2003
5
0
0
US
Okay...my other problem which i haven't resolved:

I have some DTC listbox in a form which represent data with a specific record.

When I use rs.addRecord to create a new record and then INSERT it into the db table via rs.updateRecord, all the data for each DTC is put into the insert except for the data within the listboxes--they are somehow excluded.

But, if I call updateRecord a second time (two times in a row, after explicitly setting the record's data with whats in the current selection of the listbox), the data is then put into the record in the database.

The problem is, the workaround of calling updateRecord twice won't solve the problem if the data represented by the listbox is for a field that doesn't allow NULLs into the table. So the first updateRecord will FAIL on the INSERT call because nothing is being passed to the SQL command for these fields.

So, the question is, why doesn't the field data for the record get set by whats selected by the DTC listbox imbetween the call to addRecord and updateRecord. I want to be able to have non-NULL fields in my table.

Thanks in advance,
Lehel
 
hi,
what is a DTC list box?

Known is handfull, Unknown is worldfull
 
The process for getting data from the DTC's into the recordset is quite interesting. During the update, it sends an 'event' to the DTC's. Each one that is bound to the recordset will then update the column it is bound to. You can see some of this happening if you turn on the trace feature - set the @trace= line at the top of your asp page to true.
I do not know why you get this problem, and I am sure that you could eventually find and fix the code in the _Scriptlibrary. However, if you do not want to do this then you could solve it by adding an onbeforeupdate event handler for the recordset. In this code, you could manually set the recordset column(s) to the selected values of the listbox:

(in VI, select the script outline view, select the recordset in the server objects twig, and double-click the onbeforeupdate entry. This will add a template function to your web page...)

function rsMyRecordset_onbeforeupdate()
rsMyRecordset.fields.setValue lbxList.getValue()
end function


 
Dear Friend:

1. I have created an ASP page as a dataentry form.
2. On this form I have added few DTC Listboxes as dropdowns and few DTC Recordsets.
3. When I did this the DTC control pop-up a message box telling me that the design-time control requires the visual interdev scripting object model. Then asked if I want to enable it on the page.
4. I answered yes.
5. However, when the user click the submit button it switches to the result page as I want it to do.
6. But, I want the entered data to be display in the results page.
7. But it seems that the data was not posted.
8. When I use the Response.Write Request.Form("strLName") on the resulting page it did not display any value as it was entered on the data entry form.

What can cause not to display the entered values?
 
The Script Object Model enforces some requirements on a web page, so that the DTC's will work.

One of these requirements is that the web page is ONE big form (you MUST NOT add your own FORM tag - there is already one at the very top of the HTML). This form will post back to itself - NOT to another 'results' page.

To handle this, you can:

1. Use the Show/Hide methods of the DTC controls. In thisPage_onload or mysubmit_onclick server-side methods, you can add the 'Success' or 'Results' message to the same page as the one that input the data in the first page, and adjust the things that the user sees on the page.

2. Redirect to another page. If the data that the user entered was OK, then do a redirect, else re-display the page with a validation error message.
The hard part is knowing how to transfer the data to the other page (the redirect page). You can:
2.1 place the data into the url as query string.
2.2 place the data into the session object (not recommended!)
2.3 add it to a database

To make this (2.1) easier, use the PageObjectDTC. Add a method to your Result page that takes parameters for the input values. eg:
Sub InitResultsPage(sName, nAge)...
Add this to the PageObjectDTC as a navigate function.

Go to the data-entry page, add a PageObjectDTC. Add a Reference (3rd tab) to the Results page.
NOW, in your data-entry page, you will see the name of your Results page as an object. Just start some Server-Side code and type the name of the Results page - and it will pop-up the Navigate / Execute methods. Select Navgate, and your function name (InitResultsPage) should be listed!!! Pick this, and the parameters will then be asked for. Just enter the DTC controls that you used for data entry here:
Sub pbSubmit_onclick()
'* if valid then...
Results.navigate.InitResultsPage(txtName.value, txtAge.value)
End Sub

Its easier to do than to explain - believe me!


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top