473,395 Members | 1,629 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

may be escape chars related?

Case 1
I have a variable called sConnectString whose value is [ I dynamically
generate sConnectString from the database values, so can not hardcode]

"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=\\msxp102\shared\DBS\db3.mdb;User Id=;Password=;";

after this I call following statements

sConnectString = sConnectString.Replace("\\",\\\\);

OleDbConnection myConnection = new OleDbConnection(sConnectString );

myConnection.Open();

I get error file not found.
Case 2

Where as if I do following thing it works fine (note here escape characters
are hard coded in the hard coded string)

ss = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=\\\\msxp102\\shared\\DBS\\db3.mdb;User Id=;Password=;";

OleDbConnection myConnection = new OleDbConnection(ss );

myConnection.Open();


I dont want to hard code the connection string so case 1 must run....

any thoughts


Nov 17 '05 #1
1 1275
Why don't you simply do this:

OleDbConnection myConnection = new
OleDbConnection(sConnectString.Replace(@"\",@"\\") );

That's assuming sConnectString, as generated, actually contains any
slashes what you think it does in the first place. The problem may be
in how you are generating it; it's possible that every backslash is
being interpreted somewhere along the line as an escape character and
you don't have the connection string you think you do. (Remember that
the debugger may be displaying literally what's in the string or it may
be displaying escape characters).

--Bob

abcd wrote:
Case 1
I have a variable called sConnectString whose value is [ I dynamically
generate sConnectString from the database values, so can not hardcode]

"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=\\msxp102\shared\DBS\db3.mdb;User Id=;Password=;";

after this I call following statements

sConnectString = sConnectString.Replace("\\",\\\\);

OleDbConnection myConnection = new OleDbConnection(sConnectString );

myConnection.Open();

I get error file not found.
Case 2

Where as if I do following thing it works fine (note here escape characters
are hard coded in the hard coded string)

ss = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=\\\\msxp102\\shared\\DBS\\db3.mdb;User Id=;Password=;";

OleDbConnection myConnection = new OleDbConnection(ss );

myConnection.Open();


I dont want to hard code the connection string so case 1 must run....

any thoughts

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ivo Woltring | last post by:
Dear Pythoneers, I have this app that I want to be able to present in more than 1 language. To do this I use ConfigParser with an ini file. My question: when I 'get()' the message with...
6
by: Vincent van Beveren | last post by:
Hey everyone, I try to insert a special character into my HTML using the DOM. I do this by the following piece of code: document.getElementById('space')....
4
by: swayze | last post by:
Hi, I'm sending some vars to php from javascript. These vars contain special chars (like "&" ,",")and also turkish characters. Therefore I'm using javascripts escape() function to be able to...
3
by: Paul | last post by:
I have an Access 2000 database with a form that is giving me some major headaches. When you open the form, it displays all records and allows editing, but has AllowAdditions set to False so that...
2
by: Pavils Jurjans | last post by:
Hello, I am looking fow C# equivalent of JavaScripts escape() and unescape() functions. I need to use C# function at the server side and then be able to use the opposite at the client side. ...
7
by: Luminal | last post by:
Greetings I'm having some problems on my C# application. I'm using an access database and I'm not able to do select queries with the ' character. My code is this: // some previous code like...
2
by: genc_ ymeri at hotmail dot com | last post by:
Hi , Does .Net have any method/function that escape charcters while writing a XML file ???? Thank you in advance.
15
by: pkaeowic | last post by:
I am having a problem with the "escape" character \e. This code is in my Windows form KeyPress event. The compiler gives me "unrecognized escape sequence" even though this is documented in MSDN....
4
by: Jim Langston | last post by:
I want to build a string that contains the character 1, followed by ABC followed by the characters 255 255. One would think it would be simple: std::string Data( "\x01ABC\xFF\xFF", 6); but that...
0
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
jinu1996
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.