BarneyE
|
Posted: 11/17/2004, 9:52 AM |
|
After I add a record I have a return page that displays the added record. Can I add the ID of the new record to the URL for the return page? I have editable grids that on the page that need that ID to update their tables properly.
Thanks
|
|
|
peterr
Posts: 5971
|
Posted: 11/17/2004, 12:40 PM |
|
I think that you could use the code from the "Multi-Step User Registration" in CCS Example Pack ( http://examples.codecharge.com/ExamplePack/MultiStepReg...trationGrid.php )
After the user fills out the 1st step of the registration form, there is custom code that appends the newly created ID to the URL of the next page.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
|
|
Pendarus
Posts: 10
|
Posted: 11/18/2004, 11:40 AM |
|
Peter,
Thanks for the info!!
I modified the code to fit my project, and came up with this:
Dim LastID
If IsEmpty(Request.QueryString("orderid")) Then
LastID = CCDLookup("max(orderid)","orders","", DBconnection1)
If InStr(Redirect, "?") = 0 Then
Redirect = Redirect & "?orderid=" & LastID
ElseIf Right(Redirect, 1) = "?" Then
Redirect = Redirect & "orderid=" & LastID
Else
Redirect = Redirect & "&orderid=" & LastID
End If
End If
Only problem is it doesn't work. I test the example it came from and that works great. The only thing I can think of, is my URL has a variable in it already.
http://localhost/ctsample/order_maint.asp?customerid=4
Is this an issue? What can I do to fix this?
Just some info on my project:
DB connection name is "connection1"
Table name is "Orders"
Column name is "orderid"
Varible I need added to the URL id "orderid"
Thanks!
|
|
|
mrachow
Posts: 509
|
Posted: 11/18/2004, 12:06 PM |
|
You should use the CCS functions when dealing with the query string. They will do all the syntax stuff for you.
CCAddParam(CCGetQueryString("QueryString", Empty), orderid, LastID
Regards,
Michael
_________________
Best regards,
Michael |
|
|
Pendarus
Posts: 10
|
Posted: 11/18/2004, 3:38 PM |
|
Michael,
OK tried it your way and found a problem.
Error Type:
Microsoft VBScript compilation (0x800A03EE)
Expected ')'
/CTSample/orders_maint_events.asp, line 14, column 66
CCAddParam(CCGetQueryString("QueryString", Empty), orderid, LastID
If I add the parenthese, I get:
Error Type:
Microsoft VBScript compilation (0x800A0414)
Cannot use parentheses when calling a Sub
/CTSample/orders_maint_events.asp, line 14, column 67
CCAddParam(CCGetQueryString("QueryString", Empty), orderid, LastID)
Here is the code I made from your suggestion:
Dim LastID
If IsEmpty (CCGetParam("OrderID", Empty)) Then
LastID = CCDLookup("max(orderid)","orders","", DBconnection1)
CCAddParam(CCGetQueryString("QueryString", Empty), orderid, LastID
End If
I Hate Coding!
What am I doing wrong?
|
|
|
peterr
Posts: 5971
|
Posted: 11/18/2004, 4:00 PM |
|
In regards to the previous problem, you may want to check if the LastID is being retrieved properly:
===================
Dim LastID
LastID = CCDLookup("max(orderid)","orders","", DBconnection1)
response.write ("Last ID = " & LastID)
response.end
===================
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
|
|
Pendarus
Posts: 10
|
Posted: 11/19/2004, 8:34 AM |
|
Peter,
Did the test code and the LastID value is being retrieved properly.
Thanks
|
|
|
peterr
Posts: 5971
|
Posted: 11/19/2004, 8:43 AM |
|
OK, then maybe the redirect itslf doesn't work.
Which event did you use for this?
Also try a simple test of the redirect, like:
Redirect = "www.yessoftware.com"
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
|
|
mrachow
Posts: 509
|
Posted: 11/20/2004, 12:11 AM |
|
Sorry for the missing closing brace.
And,
I often forget that ASP don't need/want brackets (at least sometimes).
Because I'm not sure which braces I can let go lets separate things.
Dim qs
If IsEmpty CCGetParam("OrderID", Empty) Then
LastID = CCDLookup("max(orderid)","orders","", DBconnection1)
qs = CCGetQueryString("QueryString", Empty)
CCAddParam(qs, orderid, LastID)
End If
Kindly regards,
Michael
_________________
Best regards,
Michael |
|
|
Pendarus
Posts: 10
|
Posted: 11/23/2004, 1:45 PM |
|
Peter,
I am using the "After Insert" event. I tried simple redirect and it did not work. The values are being set correctly but the redirect is not working.
Barney
|
|
|
peterr
Posts: 5971
|
Posted: 11/23/2004, 1:59 PM |
|
Sorry, I don't have other ideas. The example works OK. The redirect also works OK for me in After Insert.
BTW, what happens when you use the test redirect? Nothing? Just the page continues to be processed like nothing happened?
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
|
|
Pendarus
Posts: 10
|
Posted: 11/29/2004, 10:31 AM |
|
Peter,
This seems to be a symptom of a larger problem. As this project has progressed I find if I add new functions, code, links, etc some work and some do not. I find myself remaking grids from scratch and redoing the work already done to solve the problems.
Can I regenerate the entire project without starting from scratch? I think as I add and remove things the application is not cleaning up after itself and causing problems.
|
|
|
peterr
Posts: 5971
|
Posted: 11/29/2004, 12:23 PM |
|
Barney,
You can delete all generated .asp files except the event files (Page_events.asp) then press F9 to regenerate the application code. Of course you cannot regenerate .html or the events that you created manually.
There is just no way for the redirect not to work in the "After Insert" event, so based on your previous responses I'd think that you're doing something wrong and it may be best if you contacted our support when you see such problems. They can look at your project and explain what it is. Once you find out what's wrong it can save you all the trouble later.
It would also help if you answered my previous question, as then I may also be able to help you find the source of the problem.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
|
|
Pendarus
Posts: 10
|
Posted: 11/29/2004, 12:56 PM |
|
Peter,
Yep, your hit the nail on the head, the page processes like nothing happened.
A record gets added but the URL is not updated. The simple redirect you suggested does the same.
Thanks again!
|
|
|
peterr
Posts: 5971
|
Posted: 11/29/2004, 1:34 PM |
|
Hmm, I was expecting different results, therefore unfortunately I don't have other ideas and won't be able to help you further via the user forums. If no other users respond here please contact our support.
Also, I just reviewed our previous comments and I see that I was referring to the "Multi-Step User Registration" example that is based on the record form, while you're using editable grid. You initially wrote "After I add a record I have a return page that displays the added record." but I'm not sure if you were working with the Record form as well? Since you also wrote that you used the "After Insert" event then it simply must work as it works in the example.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
|
|
Barney (Pendarus)
|
Posted: 12/02/2004, 12:41 PM |
|
Test
|
|
|
Pendarus
Posts: 10
|
Posted: 12/08/2004, 9:01 AM |
|
I started the project again from scratch. So far the redirect is working. I find it dissapointing that I have to redo all the work I had done up to that point. But, it is working along with solving a few other nagging issues. I thought I was just bad at using the program. Now everything is working the way I thought it should. Very wierd.
|
|
|
|