DB Connection String Problem

B

bob

Hi,

I am trying to encrypt my connection string in the app.config file. I am
using Base64 encryption, I just want to hide it from casual users. I keep
getting file not found error. However when I just use the connection string
in plain text I can connect fine. The only difference between the two is
the @ sign is used in front of the connection string (plain) when I view
them in the command window (see below). Any ideas?
? this.connectionString
"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\WINDOWS\\system32\csdm.dll;Jet OLEDB:Database Password=passwd;"
? this.connectionString
@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\WINDOWS\\system32\csdm.dll;Jet OLEDB:Database Password=passwd;"
 
J

Jianwei Sun

bob said:
Hi,

I am trying to encrypt my connection string in the app.config file. I am
using Base64 encryption, I just want to hide it from casual users. I keep
getting file not found error. However when I just use the connection string
in plain text I can connect fine. The only difference between the two is
the @ sign is used in front of the connection string (plain) when I view
them in the command window (see below). Any ideas?



"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\WINDOWS\\system32\csdm.dll;Jet OLEDB:Database Password=passwd;"
The way you use '\' is not consistent to me, sometimes, you use "\\",
sometimes you use "\".

I believe if you use @ , you should use single '\', otherwise, you use "\\".
 
J

Jon Skeet [C# MVP]

bob said:
I am trying to encrypt my connection string in the app.config file. I am
using Base64 encryption, I just want to hide it from casual users. I keep
getting file not found error. However when I just use the connection string
in plain text I can connect fine. The only difference between the two is
the @ sign is used in front of the connection string (plain) when I view
them in the command window (see below). Any ideas?

"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\WINDOWS\\system32\csdm.dll;Jet OLEDB:Database Password=passwd;"
@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\WINDOWS\\system32\csdm.dll;Jet OLEDB:Database Password=passwd;"

Yeah - don't use the debugger to show you the contents of strings. It
can be very confusing.

See http://www.pobox.com/~skeet/csharp/strings.html in particular, the
sections on literals and the debugger.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top