Solved

Concatenate String with Apostrophe

Posted on 2013-11-20
10
791 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
Industry Leaders: 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

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

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.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

685 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