Hello!
I am trying to connect to a SQL Server (MSDE) database in mixed mode
authentication, via C#, but when I use the MSDE instance name, I keep
getting an "Unrecognized Escape Sequence" error. The Data Source name
has a backslash in it, and I'm guessing that this is causing the
problem. How do I "Escape" the name, to make this work? I'm able to
connnect in the .NET developement platform (Tools / Connect To
Database), etc, using the full MSDE instance name, ie,
SWC_K7\CHRISMON1, but when I call that from code, the compiler catches
it as an error.
Connect String:
conn = new SqlConnection("Data Source=SWC_K7\CHRISMON1;
User Id=yadda;
password=yadda;
Initial Catalog=ChrismonContacts");
Thanks!
Steven 5 8080
Steven:
In C#, using the "@" symbol in front of a string wills escape it. There are
many other instances, particularly when dealing with Paths, Files, Regular
Expressions that this is very handy. You can either replace each single
instance of "\" with "\\" or use the @ Symbol: conn = @"Data
Source=SWC_K7\CHRISMON1;User Id=yadda; password=yadda;
Initial Catalog=ChrismonContacts");
<Steven C> wrote in message
news:ld********************************@4ax.com... Hello!
I am trying to connect to a SQL Server (MSDE) database in mixed mode authentication, via C#, but when I use the MSDE instance name, I keep getting an "Unrecognized Escape Sequence" error. The Data Source name has a backslash in it, and I'm guessing that this is causing the problem. How do I "Escape" the name, to make this work? I'm able to connnect in the .NET developement platform (Tools / Connect To Database), etc, using the full MSDE instance name, ie, SWC_K7\CHRISMON1, but when I call that from code, the compiler catches it as an error.
Connect String:
conn = new SqlConnection("Data Source=SWC_K7\CHRISMON1; User Id=yadda; password=yadda; Initial Catalog=ChrismonContacts");
Thanks!
Steven
The backslash is the escape character. Type "SWC_K7\\CHRISMON1" in the
connection string.
<Steven C> wrote in message
news:ld********************************@4ax.com... Hello!
I am trying to connect to a SQL Server (MSDE) database in mixed mode authentication, via C#, but when I use the MSDE instance name, I keep getting an "Unrecognized Escape Sequence" error. The Data Source name has a backslash in it, and I'm guessing that this is causing the problem. How do I "Escape" the name, to make this work? I'm able to connnect in the .NET developement platform (Tools / Connect To Database), etc, using the full MSDE instance name, ie, SWC_K7\CHRISMON1, but when I call that from code, the compiler catches it as an error.
Connect String:
conn = new SqlConnection("Data Source=SWC_K7\CHRISMON1; User Id=yadda; password=yadda; Initial Catalog=ChrismonContacts");
Thanks!
Steven
Awesome!
This worked.
Thanks, gentlemen
Steven C This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: /dev/null |
last post by:
Is there a function in php that you can pass a string headed for a mysql
query and have it make it 'safe'? For example it would escape out the '
found in the string.
Thanks!
|
by: Dave Smithz |
last post by:
Having adopted someone else's PHP cope and completing a crash course in the
language I came across a (probably common) problem with the current code.
On a registration form, whenever users names...
|
by: Lyn |
last post by:
We use response.redirect to connect to an external web site which
does not work when the "=" sign is translated to "%3B" and the ";"
to "%3D". Is there a way to turn this default translation off?...
|
by: Lyn |
last post by:
We use response.redirect to connect to an external
web site which does not work when the "=" sign is
translated to "%3B" and the ";" to "%3D". Is there
a way to turn this default translation off?...
|
by: ryan.fairchild |
last post by:
Ok I basically am creating a container for a bunch of other <div> tags.
But I want to make four jpegs/gif/whatever that goes in each corner so
they look rounded.
I thought this is how I would do...
|
by: Peter |
last post by:
Hi:
How could I escape "{" in Console.Write(), i.e. I want output like -- { 1234
}, how could I do it in one Console.Write()?
thx.
|
by: Prince Kumar |
last post by:
I am trying to escape the special characters while executing the
following sql, but couldn't figure out a way.
db2_all "db2 connect to mydb; db2 select * from table
(SNAPSHOT_CONTAINER ( '' , -1...
|
by: Tim Marshall |
last post by:
What is the docmd.runcommand accmd? for the equivalent of pressing the
escape button when adding a record to a table?
I'm setting up a bound form and would like to have a "cancel" button
that...
|
by: YiFai |
last post by:
Hello,
I'm currently writing a directx program with C++, but it takes a while to
load the files necessary for the directx. When the directx window loads, it
can quit the program with the...
|
by: Jeff Groves |
last post by:
I'm using FreezePython on a Python program that uses wxPython and subprocess.
The result almost works, but it always hits this bug:
File "velauncher.py", line 847, in Launch
File...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |