Solved

Imbedded doublequotes in string

Posted on 2004-09-06
3
213 Views
Last Modified: 2010-04-15
Hey,

I;ve been screwing around with this for an hour and finally decided to ask you all. I am trying to build a javascript array

scriptstr = @"<script language=""javascript""> var evArray = [";
bool first = true;
while(oDr.Read())
{
      if (first) first = false;
      else scriptstr += ",";
      scriptstr += @"["";
      scriptstr += oDr["companyname"].ToString();
      scriptstr += @"","";
      scriptstr += oDr["codename"].ToString();
      scriptstr += @"","";
      scriptstr += oDr["amendnum"].ToString();
      scriptstr += @"","";
      scriptstr += oDr["waivernum"].ToString();
      scriptstr += @"","";
      scriptstr += oDr["duedate"].ToString();
      scriptstr += @""]";
}

I thought that with a literal string, using two double quotes was the way to get a double quote in the string. But the compiler does not like it at all!

Where am I going wrong?

Thanks
0
Comment
Question by:RichardFox
[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
  • 3
3 Comments
 
LVL 10

Accepted Solution

by:
eternal_21 earned 250 total points
ID: 11992609
You are forgetting to put the whole string in quotes...  So if you want add the string:

  ","

you would code it as:

  @""","""

  or

  "\",\""
0
 
LVL 10

Expert Comment

by:eternal_21
ID: 11992627
I think this is what you meant to do:

  scriptstr = @"<script language=""javascript""> var evArray = [";
  bool first = true;
  while(oDr.Read())
  {
    if (first) first = false;
    else scriptstr += ",";
    scriptstr += @"[""";
    scriptstr += oDr["companyname"].ToString();
    scriptstr += @""",""";
    scriptstr += oDr["codename"].ToString();
    scriptstr += @""",""";
    scriptstr += oDr["amendnum"].ToString();
    scriptstr += @""",""";
    scriptstr += oDr["waivernum"].ToString();
    scriptstr += @""",""";
    scriptstr += oDr["duedate"].ToString();
    scriptstr += @"""]";
  }
0
 
LVL 10

Expert Comment

by:eternal_21
ID: 11997857
Did that help you RichardFox?
0

Featured Post

Independent Software Vendors: 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

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

734 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