PC Review Forums Newsgroups Microsoft DotNet Microsoft ADO .NET ConnectionStringBuilder: Automatic quoting problem

Reply

ConnectionStringBuilder: Automatic quoting problem

 
Thread Tools Rate Thread
Old 18-06-2006, 03:07 AM   #1
Michael Russell
Guest
 
Posts: n/a
Default ConnectionStringBuilder: Automatic quoting problem


I've got a form that allows the user to enter the information to build a
connection string for various data connection types. I've run into a
problem testing the ODBC for a dsn-less connection, using a MS Access
database.

I fill out the minimum required information (Driver and Datasource/Dbq),
but the string would always fail to open a connection.

This is the code used:
csb.Add( "Driver", settings.Driver );
csb.Add( "Dbq", settings.DataSource );

This is an example of what the CSB would return:
Driver="{Microsoft Access Driver (*.mdb)}";Dbq=d:\work\reporter1.mdb

What I found to be the problem is the quoting around the Driver text,
which is added autmomatically by the CSB. If I remove the quotes before
using the string, then it works perfectly.

Doing some reading, I saw a reference that indicated that this quoting
is done as a security measure to prevent injection attacks. Am I using
the ConnectionStringBuilder incorrectly?

Michael
  Reply With Quote
Old 18-06-2006, 07:27 AM   #2
Cor Ligthert [MVP]
Guest
 
Posts: n/a
Default Re: ConnectionStringBuilder: Automatic quoting problem

Micheel

The same as to David, why using ODBC it is limited in all kind of designers.
For your Jet (access) database is OleDB the best.

Cor

"Michael Russell" <mr_b15h0p@hotmail.com> schreef in bericht
news:O4jbwvnkGHA.836@TK2MSFTNGP02.phx.gbl...
> I've got a form that allows the user to enter the information to build a
> connection string for various data connection types. I've run into a
> problem testing the ODBC for a dsn-less connection, using a MS Access
> database.
>
> I fill out the minimum required information (Driver and Datasource/Dbq),
> but the string would always fail to open a connection.
>
> This is the code used:
> csb.Add( "Driver", settings.Driver );
> csb.Add( "Dbq", settings.DataSource );
>
> This is an example of what the CSB would return:
> Driver="{Microsoft Access Driver (*.mdb)}";Dbq=d:\work\reporter1.mdb
>
> What I found to be the problem is the quoting around the Driver text,
> which is added autmomatically by the CSB. If I remove the quotes before
> using the string, then it works perfectly.
>
> Doing some reading, I saw a reference that indicated that this quoting is
> done as a security measure to prevent injection attacks. Am I using the
> ConnectionStringBuilder incorrectly?
>
> Michael



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off