Solved

Concatenate String with Apostrophe

Posted on 2013-11-20
10
792 Views
Last Modified: 2013-11-25
Trying to concatenate a string and include apostrophes in the string between the startdate and enddate (not double quotes). I have not got it to work. Please see below code as to what I have now.

Thanks in advance.

Response.Write "<a href='loginreportselect.asp?adminemployeeid=" & EmployeeID & "&startdate=" & chr(39) & frmStartDate & chr(39) & "&enddate=" & chr(39) & frmEndDate & chr(39) & "'>Test</a>"

Open in new window

0
Comment
Question by:mathew_s
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
10 Comments
 
LVL 70

Expert Comment

by:Qlemo
ID: 39663485
Usually you just use two single quotes to make one in a string:
Response.Write "<a href='loginreportselect.asp?adminemployeeid=" & EmployeeID & "&startdate=''" & frmStartDate & "''&enddate='''" & frmEndDate & "'''>Test</a>"

Open in new window

0
 
LVL 33

Expert Comment

by:Big Monty
ID: 39663489
why are you surrounding the querystring variables by single quotes?
0
 
LVL 1

Author Comment

by:mathew_s
ID: 39663605
Qlemo - Nothing is displaying in the url after the &startdate=
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:mathew_s
ID: 39663613
Surrounding dates by apostrophe. This is needed otherwise it won't work.
0
 
LVL 1

Author Comment

by:mathew_s
ID: 39663629
These are the dates as an example:

August 19, 2013
November 20, 2013
0
 
LVL 33

Expert Comment

by:Big Monty
ID: 39663634
a query string is made up of key/value pairs, such as:

abc.com?var1=someValue1&var2=someValue2

no need for quotes in the string, in fact, it'll cause potential problems on both the client side (as you're experiencing) and the server side.

When you do a Request.QueryString("startDate"), your returned value would be:

"1/1/2000"

instead of 1/1/2000

i think you may confusing javascript with straight up html, you should be able to do:

Response.Write "<a href='loginreportselect.asp?adminemployeeid=" & EmployeeID & "&startdate=" & frmStartDate & "&enddate=" & frmEndDate & "'>Test</a>"
0
 
LVL 1

Author Comment

by:mathew_s
ID: 39663674
OK we are getting there see below on what I get....but I need the quotes between the dates for it to work. I am not sure why it may have to do with how this program is developed but I don't want to go there just need to get this to work.
Error message below.

http://xxx/loginreportselect.asp?adminemployeeid=522036&startdate=August 19, 2013&enddate=November 20, 2013



 Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
 [Microsoft][ODBC driver for Oracle][Oracle]ORA-00907: missing right parenthesis
 /loginreportselect.asp, line 223
0
 
LVL 33

Assisted Solution

by:Big Monty
Big Monty earned 250 total points
ID: 39663697
are you putting the url into a javascript function?

anyways, you don't need quotes, but you do need to encode it since it has spaces in it:

dim url
url = "loginreportselect.asp?adminemployeeid=" & EmployeeID & "&startdate=" & frmStartDate & "&enddate=" & frmEndDate & "
url = Server.HTMLEncode( url )

Response.Write "<a href = '" & url & "'>Test</a>"

note the single quotes still enclose the href
0
 
LVL 1

Accepted Solution

by:
mathew_s earned 0 total points
ID: 39663911
This worked for me. Thanks for the help.

url = "loginreportselect.asp?adminemployeeid=" & EmployeeID & "&startdate=" & Server.URLEncode(Request.QueryString("startdate")) & "&enddate=" & Server.URLEncode(Request.QueryString("enddate"))

Response.Write "<a href = " & url & ">Test</a>"

Open in new window

0
 
LVL 1

Author Closing Comment

by:mathew_s
ID: 39674131
The_Big_Daddy  comments directed me to the correct solution. In the end, still had to do some tinkering to get it to work and use URLEncode instead of HTMLEncode.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
IIS 7 and executing pages using localhost 16 30
how to loop through and process two columns in excel 8 71
Validating Date 4 38
How to post data to an API using ASP Classic 3 50
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question