Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Concatenate String with Apostrophe

Posted on 2013-11-20
10
Medium Priority
?
842 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 71

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 34

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 34

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 34

Assisted Solution

by:Big Monty
Big Monty earned 1000 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

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!

Question has a verified solution.

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

I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

636 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