Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Imbedded doublequotes in string

Posted on 2004-09-06
3
Medium Priority
?
222 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
  • 3
3 Comments
 
LVL 10

Accepted Solution

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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Screencast - Getting to Know the Pipeline

972 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