Solved

Imbedded doublequotes in string

Posted on 2004-09-06
3
203 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 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

810 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