Forums
This topic is locked
Display Data
29 Apr 2004 14:13:28 Reg Coles posted:
Created a insert data page which inserts data into MS SQL and then returns to menu page, instead of going to a menu page can the insert data page go to another page which displays the data just entered for printing purposes. Looked at related pages but it just displays the first record in the database also tried show last record and move to specific record.Any suggestions.
Thanks
Replies
Replied 29 Apr 2004 14:44:26
29 Apr 2004 14:44:26 Vince Baker replied:
when i need to do this without access (there is a behaviour available that does just that but doesnt work with MySQL or SQL Server) i insert record as normal, then go to a second page that will obtain the id of your new record and then direct you straight to the next page to print.
Basically, this middle page has a recordset on it that orders your table by your ID in descending order. So when you query it for the first record it will get your newely inserted record.
Then, use the code below to redirect to your new page.
<% response.redirect("your_print_page?uniqueid=" & rsYourrecordset("Your_ID_FIeld"
%>
then on the print page, filter the record by the uniqueid value in the querystring
Regards
Vince
Visit my home: www.chez-vince.com
VBScript | ASP | HTML | SQL | Oracle | Hosting
Basically, this middle page has a recordset on it that orders your table by your ID in descending order. So when you query it for the first record it will get your newely inserted record.
Then, use the code below to redirect to your new page.
<% response.redirect("your_print_page?uniqueid=" & rsYourrecordset("Your_ID_FIeld"

then on the print page, filter the record by the uniqueid value in the querystring
Regards
Vince
Visit my home: www.chez-vince.com
VBScript | ASP | HTML | SQL | Oracle | Hosting
Replied 29 Apr 2004 19:18:37
29 Apr 2004 19:18:37 Reg Coles replied:
Done the recordset on the 2nd page and put the redirect code on the page as well but I get the following error:
Microsoft VBScript compilation (0x800A03EE)
Expected ')'
/print1.asp, line 24, column 77
response.redirect("print.asp?uniqueid=Main_Advisor" & rsPrint("Main_Advisor"
The redirect page is called print1.asp and it's going to print.asp.The recordset is setup as follows:
Filter: Main_Advisor =
URL: Main_Advisor
Sort: Main_advisor = Desending
Also tried with your code in URL but came up with another error.
I think I'm either entering the code in wrong or putting it in the wrong place.
Thanks
Microsoft VBScript compilation (0x800A03EE)
Expected ')'
/print1.asp, line 24, column 77
response.redirect("print.asp?uniqueid=Main_Advisor" & rsPrint("Main_Advisor"

The redirect page is called print1.asp and it's going to print.asp.The recordset is setup as follows:
Filter: Main_Advisor =
URL: Main_Advisor
Sort: Main_advisor = Desending
Also tried with your code in URL but came up with another error.
I think I'm either entering the code in wrong or putting it in the wrong place.
Thanks
Replied 29 Apr 2004 19:44:13
29 Apr 2004 19:44:13 Vince Baker replied:
<% response.redirect("your_print_page?uniqueid=" & rsYourrecordset("Your_ID_FIeld"
%> should have been
<% response.redirect("your_print_page?uniqueid=" & rsYourrecordset("Your_ID_FIeld"
)%>
My fault missed off a closing bracket sorry. here is the code based on your field names:
<%response.redirect("print.asp?Main_Advisor=" & rsPrint("Main_Advisor"
)%>
Regards
Vince
Visit my home: www.chez-vince.com
VBScript | ASP | HTML | SQL | Oracle | Hosting

<% response.redirect("your_print_page?uniqueid=" & rsYourrecordset("Your_ID_FIeld"

My fault missed off a closing bracket sorry. here is the code based on your field names:
<%response.redirect("print.asp?Main_Advisor=" & rsPrint("Main_Advisor"

Regards
Vince
Visit my home: www.chez-vince.com
VBScript | ASP | HTML | SQL | Oracle | Hosting
Replied 30 Apr 2004 12:52:52
30 Apr 2004 12:52:52 Reg Coles replied:
Getting another error now Vince,
Exception occurred.
/print1.asp, line 24
Line 24 is the redirect code.
Here's code for page:
Dim rs_data__MMColParam
rs_data__MMColParam = "1"
If (Request.QueryString("Main_Advisor"
<> ""
Then
rs_data__MMColParam = Request.QueryString("Main_Advisor"
End If
Dim rs_data
Dim rs_data_numRows
Set rs_data = Server.CreateObject("ADODB.Recordset"
rs_data.ActiveConnection = MM_PrestburyTraining_STRING
rs_data.Source = "SELECT * FROM dbo._Contact WHERE Main_Advisor = '" + Replace(rs_data__MMColParam, "'", "''"
+ "' ORDER BY Main_Advisor DESC"
rs_data.CursorType = 0
rs_data.CursorLocation = 2
rs_data.LockType = 3
rs_data.Open()
rs_data_numRows = 0
response.redirect("print.asp?Main_Advisor=" & rs_data("Main_Advisor"
)
Only thing changed is the recoredset name to rs_data but everything else the same. Am I putting the redirect code in the right place. Tried it in the body of page and same error.
Thanks once again.
Exception occurred.
/print1.asp, line 24
Line 24 is the redirect code.
Here's code for page:
Dim rs_data__MMColParam
rs_data__MMColParam = "1"
If (Request.QueryString("Main_Advisor"


rs_data__MMColParam = Request.QueryString("Main_Advisor"

End If
Dim rs_data
Dim rs_data_numRows
Set rs_data = Server.CreateObject("ADODB.Recordset"

rs_data.ActiveConnection = MM_PrestburyTraining_STRING
rs_data.Source = "SELECT * FROM dbo._Contact WHERE Main_Advisor = '" + Replace(rs_data__MMColParam, "'", "''"

rs_data.CursorType = 0
rs_data.CursorLocation = 2
rs_data.LockType = 3
rs_data.Open()
rs_data_numRows = 0
response.redirect("print.asp?Main_Advisor=" & rs_data("Main_Advisor"

Only thing changed is the recoredset name to rs_data but everything else the same. Am I putting the redirect code in the right place. Tried it in the body of page and same error.
Thanks once again.
Replied 30 Apr 2004 13:36:40
30 Apr 2004 13:36:40 Vince Baker replied:
strange,
Lets try a couple of tests, firstly lets remove the fields from the end to make sure the redirect is working.
Change the code to:
response.redirect("print.asp?Main_Advisor="
and check that that works.
if that works, we have a problem getting date out of your table, are you sure there are records in there? if not that would cause an error.
Also, (this really shouldnt make any difference but lets try it anyway)
change the code to:
response.redirect("print.asp?Main_Advisor=" & rs_Data.fields.item("Main_Advisor"
.value)
Regards
Vince
Visit my home: www.chez-vince.com
VBScript | ASP | HTML | SQL | Oracle | Hosting
Lets try a couple of tests, firstly lets remove the fields from the end to make sure the redirect is working.
Change the code to:
response.redirect("print.asp?Main_Advisor="

and check that that works.
if that works, we have a problem getting date out of your table, are you sure there are records in there? if not that would cause an error.
Also, (this really shouldnt make any difference but lets try it anyway)
change the code to:
response.redirect("print.asp?Main_Advisor=" & rs_Data.fields.item("Main_Advisor"

Regards
Vince
Visit my home: www.chez-vince.com
VBScript | ASP | HTML | SQL | Oracle | Hosting
Replied 30 Apr 2004 16:05:00
30 Apr 2004 16:05:00 Reg Coles replied:
Got new errors this time:
Error Type:
ADODB.Field (0x800A0BCD)
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
/print.asp, line 56
The above error is when checking redirect.
Error Type:
ADODB.Field (0x800A0BCD)
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
/print1.asp, line 24
This error is when we change code by adding value.
On both times the data is entered in SQL, the insert is working. On the insert form it is set to 'POST'.
SO it looks like the data is not coming over to the next page.
Error Type:
ADODB.Field (0x800A0BCD)
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
/print.asp, line 56
The above error is when checking redirect.
Error Type:
ADODB.Field (0x800A0BCD)
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
/print1.asp, line 24
This error is when we change code by adding value.
On both times the data is entered in SQL, the insert is working. On the insert form it is set to 'POST'.
SO it looks like the data is not coming over to the next page.
Replied 30 Apr 2004 16:18:23
30 Apr 2004 16:18:23 Vince Baker replied:
i think I see the error,
Lets just go over your page setup.
1. You have a page that has the insert server behaviour.
2. when you configure the insert action you are stating what page to go to after insertion.
3. on this page you have a recordset that MUST not be filtered by anything, it just gets all records and is ordered by your main_advisor field.
4. under this recordset you have the response.redirect command.
5. on the third page that is the actual print page that you want to show for the latest record entered you filter this recordset on the querystring value main_advisor.
-----------
I think that you are trying to filter the recordset on the second page by a querystring but you dont need to do this. just
SELECT *
FROM dbo._Contact
ORDER BY Main_Advisor DESC
the recordset on your third page must be filtered by the querystring.
Regards
Vince
Visit my home: www.chez-vince.com
VBScript | ASP | HTML | SQL | Oracle | Hosting
Lets just go over your page setup.
1. You have a page that has the insert server behaviour.
2. when you configure the insert action you are stating what page to go to after insertion.
3. on this page you have a recordset that MUST not be filtered by anything, it just gets all records and is ordered by your main_advisor field.
4. under this recordset you have the response.redirect command.
5. on the third page that is the actual print page that you want to show for the latest record entered you filter this recordset on the querystring value main_advisor.
-----------
I think that you are trying to filter the recordset on the second page by a querystring but you dont need to do this. just
SELECT *
FROM dbo._Contact
ORDER BY Main_Advisor DESC
the recordset on your third page must be filtered by the querystring.
Regards
Vince
Visit my home: www.chez-vince.com
VBScript | ASP | HTML | SQL | Oracle | Hosting
Replied 30 Apr 2004 16:36:18
30 Apr 2004 16:36:18 Reg Coles replied:
Vince you're a star, that works,is there anyway of removing the word 'last' from top of screen.
Any suggestions of good books to read concerning asp,sql so I can learn more.
Thank you once again for the help.
It was the filtering on the wrong page. I was doing the filtering on the second page.
Any suggestions of good books to read concerning asp,sql so I can learn more.
Thank you once again for the help.
It was the filtering on the wrong page. I was doing the filtering on the second page.
Replied 30 Apr 2004 16:40:25
30 Apr 2004 16:40:25 Vince Baker replied:
Glad i could help....i remember first time I wanted to do what you are doing was a nightmare...
As for good reading, you will find loads of articles on this site and just recently a new offer of premium articles is available. These are key things we as programmers all try to do written by highly skilled developers. Well worth the small sum charged....
Go to the home page of this site and take a look around, you will learn loads!
Not sure what you mean by the way when you say remove the word last from top of screen.....
Regards
Vince
Visit my home: www.chez-vince.com
VBScript | ASP | HTML | SQL | Oracle | Hosting
As for good reading, you will find loads of articles on this site and just recently a new offer of premium articles is available. These are key things we as programmers all try to do written by highly skilled developers. Well worth the small sum charged....
Go to the home page of this site and take a look around, you will learn loads!
Not sure what you mean by the way when you say remove the word last from top of screen.....
Regards
Vince
Visit my home: www.chez-vince.com
VBScript | ASP | HTML | SQL | Oracle | Hosting
Replied 30 Apr 2004 16:42:43
30 Apr 2004 16:42:43 Reg Coles replied:
Sorry I typed 'last' while fixing page - my mistake.
Will have a look around.
Cheers for now.
Will have a look around.
Cheers for now.