Unrecognized escape sequence

Discussion in 'ASP .Net' started by Jeff, Jun 30, 2006.

  1. Jeff

    Jeff Guest

    Hey

    asp.net 2.0

    I'm developing a website using visual web developer 2005 express. In this
    project I'm trying to connect to the aspnetdb.mdf database (the project's
    own database created by wvd).

    This is my connection string:
    SqlConnection conn = new SqlConnection("Data Source=.\SQLEXPRESS;Integrated
    Security=True;");

    But the "\" in the connection string gives this error :
    "unrecognized escape sequence"
    But at this link they are using "\":
    http://msdn2.microsoft.com/en-us/library/ms247257(d=printer).aspx

    Any ideas what I should fix in my connection string so I can connect to the
    database?

    Jeff
     
    Jeff, Jun 30, 2006
    #1
    1. Advertising

  2. On Fri, 30 Jun 2006 21:49:15 +0200, "Jeff"
    <> wrote:

    >Hey
    >
    >asp.net 2.0
    >
    >I'm developing a website using visual web developer 2005 express. In this
    >project I'm trying to connect to the aspnetdb.mdf database (the project's
    >own database created by wvd).
    >
    >This is my connection string:
    >SqlConnection conn = new SqlConnection("Data Source=.\SQLEXPRESS;Integrated
    >Security=True;");
    >
    >But the "\" in the connection string gives this error :
    >"unrecognized escape sequence"
    >But at this link they are using "\":
    >http://msdn2.microsoft.com/en-us/library/ms247257(d=printer).aspx
    >
    >Any ideas what I should fix in my connection string so I can connect to the
    >database?
    >
    >Jeff
    >


    The \ character is used as the escape character in C#. This lets you use
    things like \n for the newline character. Thus to put a \ in a C# string
    you need to use \\ for one \.

    new SqlConnection("Data Source=.\\SQLEXPRESS;Integrated Security=True;")

    Alternativly you can place an @ at the start of the string (before the
    quote character) to tell C# not to use escape characters for this
    string.

    new SqlConnection(@"Data Source=.\\SQLEXPRESS;Integrated
    Security=True;")
     
    Chris Chilvers, Jul 1, 2006
    #2
    1. Advertising

  3. Jeff

    mansoorbhai

    Joined:
    Jun 21, 2011
    Messages:
    1
    ERROR:unrecognized escape sequence

    OleDbConnection conn;
    OleDbCommand comm;
    OleDbDataReader dr;
    conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\data1\jana.mdb");
    comm = new OleDbCommand("insert into mans1 values('" + TextBox1.Text + "','" + TextBox2.Text + "')", conn);
    conn.Open();
    dr = comm.ExecuteReader();
    conn.Close();


    Here i got a error about the ms access connection string(unrecognized escape sequence).........

    Also i tried { @"Data Source=C:\data1\jana.mdb" AND
    "Data Source=C:\\data1\\jana.mdb" }......

    what should i do......
     
    mansoorbhai, Jun 21, 2011
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. h babu
    Replies:
    1
    Views:
    415
    Vidar Petursson
    Jul 16, 2003
  2. marcia

    escape sequence \n

    marcia, Aug 28, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    558
    marcia
    Aug 28, 2003
  3. slomo
    Replies:
    5
    Views:
    1,572
    Duncan Booth
    Dec 2, 2007
  4. Douglas Alan
    Replies:
    66
    Views:
    2,370
    Nobody
    Aug 17, 2009
  5. Francois Massion

    nested quantifier or unrecognized escape error

    Francois Massion, Jun 2, 2006, in forum: Perl Misc
    Replies:
    6
    Views:
    187
    Mirco Wahab
    Jun 2, 2006
Loading...

Share This Page