connection issue

Page 1 of 1

1 Replies - 310 Views - Last Post: 04 October 2012 - 07:38 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=294239&amp;s=29eb45ebd730d3e7ded78b11d17d8a74&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

#1 chenaz

Reputation: 0
• Posts: 82
• Joined: 24-November 11

connection issue

Posted 04 October 2012 - 07:23 AM

hi guys ,
as i mentioned, i had problem connecting to database. whenever i click run, error will occurse at my datasourcesaying(Error 1 Unrecognized escape sequence ) which is at this line
```ata Source=AIZHONG-LAPTOP\SQLEXPRESS;Initial Catalog=test11;Integrated Security=True")
```

if i remove the \SQLexpress
another error occurred when i click the button. saying ( a network related instance. check the connection name or blablabla.)
i copy the orginal name from the database propertise which i don think is wrong. anyone is kind enough to enlighten me?

``` protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("Data Source=AIZHONG-LAPTOP\SQLEXPRESS;Initial Catalog=test11;Integrated Security=True");
SqlCommand cmd;
conn.Open();
cmd=new SqlCommand("select * from logg where name='"+ TextBox1.Text +"'and pass='"+TextBox2.Text +"'",conn);

{
Label3.Text="u are logged in";
}
```

Is This A Good Question/Topic? 0

Replies To: connection issue

#2 Curtis Rutland

• （╯°□°）╯︵ (~ .o.)~

Reputation: 4440
• Posts: 7,721
• Joined: 08-June 10

Re: connection issue

Posted 04 October 2012 - 07:38 AM

That's because \ begins an escape sequence. \n is new line, \t is tab, \u+#### is a unicode character (if you replace the # with numbers). There are two ways to get around escape sequences: you can add another \ to your string. \\ escapes to \

Also, you can prefix your string with the @ character. That makes a string a "verbatim string", meaning that there will be no escaping performed.

Two examples:

```string path = "c:\\dev\\test.txt";
string path2 = @"c:\dev\test.txt";
```

That should tell you enough to fix your code.