On Feb 16, 11:12 am, "Ignacio Machin \( .NET/ C# MVP \)" <machin TA
laceupsolutions.com> wrote:
> Hi,
>
> <esro...@msn.com> wrote in message
>
> news:(E-Mail Removed)...
>
> > Would like to replace Data Source mdb location and name with a string
> > variable. For example:
>
> > where I have
Ignacio,
I wish it was that easy. Here is what I'm actually using:
strDBLocation=@"Provider=Microsoft.JET.OLEDB.4.0;Data Source=f:
\Cresi2\MyStuff.mdb;Jet OLEDB

atabase Password="+DBPassWord;
If I substitute a variable after Data Source =, the compiler will not
coginize it. The only place where I have been able to substitue a var
is at the end. I have tried to break this down into different strings
and add them to gether, but nothing works.
>
> > @"Data Source = c:\mydirectory\mydatabase.mdb;" +
>
> > the c:\mydirectory\mydatabase.mdb would be replaced with a variable.
>
> I do not understand where is the problem, you can have the connection string
> split in several string vars and just do like
>
> OleDbConnection c = new OleDbConnection( str1 + str2 );
>
> --
> Ignacio Machin
> machin AT laceupsolutions com