Solved

Concatenate String with Apostrophe

Posted on 2013-11-20
10
786 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 69

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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

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…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

828 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