Solved

Concatenate String with Apostrophe

Posted on 2013-11-20
10
775 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
  • 6
  • 3
10 Comments
 
LVL 68

Expert Comment

by:Qlemo
Comment Utility
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 32

Expert Comment

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

Author Comment

by:mathew_s
Comment Utility
Qlemo - Nothing is displaying in the url after the &startdate=
0
 
LVL 1

Author Comment

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

Author Comment

by:mathew_s
Comment Utility
These are the dates as an example:

August 19, 2013
November 20, 2013
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 32

Expert Comment

by:Big Monty
Comment Utility
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
Comment Utility
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 32

Assisted Solution

by:Big Monty
Big Monty earned 250 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Welcome, welcome!  If you are new to the series and haven't been following along, please take a brief moment to review the first three installments: Part 1 (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/A_266-VBScri…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now