473,394 Members | 1,840 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,394 software developers and data experts.

Data Source for mdb connection

Would like to replace Data Source mdb location and name with a string
variable. For example:

where I have

@"Data Source = c:\mydirectory\mydatabase.mdb;" +

the c:\mydirectory\mydatabase.mdb would be replaced with a variable.

Thanks Bob J.

Feb 16 '07 #1
4 5782
Hi,

<es*****@msn.comwrote in message
news:11*********************@p10g2000cwp.googlegro ups.com...
Would like to replace Data Source mdb location and name with a string
variable. For example:

where I have

@"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
Feb 16 '07 #2
Hello es*****@msn.com,

Maybe u need to use smth like string.Format("Data Source = {0};" , YouString)?!
Would like to replace Data Source mdb location and name with a string
variable. For example:

where I have

@"Data Source = c:\mydirectory\mydatabase.mdb;" +

the c:\mydirectory\mydatabase.mdb would be replaced with a variable.

Thanks Bob J.
---
WBR, Michael Nemtsev [C# MVP].
My blog: http://spaces.live.com/laflour
Team blog: http://devkids.blogspot.com/

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
Feb 16 '07 #3
On Feb 16, 11:12 am, "Ignacio Machin \( .NET/ C# MVP \)" <machin TA
laceupsolutions.comwrote:
Hi,

<esro...@msn.comwrote in message

news:11*********************@p10g2000cwp.googlegro ups.com...
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;D ata Source=f:
\Cresi2\MyStuff.mdb;Jet OLEDB:Database 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

Feb 16 '07 #4
Hi,

<es*****@msn.comwrote in message
news:11*********************@a75g2000cwd.googlegro ups.com...
On Feb 16, 11:12 am, "Ignacio Machin \( .NET/ C# MVP \)" <machin TA
laceupsolutions.comwrote:
>Hi,

<esro...@msn.comwrote in message

news:11*********************@p10g2000cwp.googlegr oups.com...
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;D ata Source=f:
\Cresi2\MyStuff.mdb;Jet OLEDB:Database Password="+DBPassWord;
string db = @"f:\Cresi2\MyStuff.mdb";

string strDBLocation = "Provider=Microsoft.JET.OLEDB.4.0;Data Source=" + db
+ ;Jet OLEDB:Database Password="+DBPassWord;
That should work.

Ps:
I think that using String.Format improve the readiness:

string strDBLocation = String.Format(
"Provider=Microsoft.JET.OLEDB.4.0;Data Source={0}:Database Password={1}",
DBLocation , DBPassWord );

--
Ignacio Machin
machin AT laceupsolutions com
Feb 16 '07 #5

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

Similar topics

1
by: Mike P | last post by:
I'm trying to take some data from an Excel spreadsheet, put it into a dataset, and then update a SQL table with the data. I'm not 100% sure I'm doing this right, can somebody tell me what I'm...
2
by: Kenneth P | last post by:
Hi, MySql AB released their .NET Native Driver 1 Sept 2004 and I'm trying to create a connectionstring that works according to their examples, see below my example I've installed their...
5
by: petro | last post by:
Hello all, My asp.net web application works on my machine but I get the following error on our test web server, There is only one oracle home on the test server. Does anyone know how to resolve...
5
by: rogsonl | last post by:
My computer was moved last week, and the company changed the network groups we work on. As a result, one of the main benefits from Whidbey (database connectivity) no longer works. Situation: 1....
0
by: pd123 | last post by:
I'm new to C# and .net and I'm trying to create a form that will register users in a sql server database. I have the following code but when I run the code I get an error " The name 'Peter' is...
3
by: D | last post by:
Hello everyone I have developed a web application using .asp to access a data source on a different server than where my .asp files are stored. I've tried to determine how to establish this...
0
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted...
2
by: Orit | last post by:
Hello . Please find below my questions - I hope some of the ASP.NET experts of this forum will answer to those beginner's questions : My Web site should be able to work with either SQL Server...
6
Cintury
by: Cintury | last post by:
Hi all, I've developed a mobile application for windows mobile 5.0 that has been in use for a while (1 year and a couple of months). It was developed in visual studios 2005 with a back-end sql...
7
Merlin1857
by: Merlin1857 | last post by:
Its great producing data for users to look at in your web pages and generally that is sufficient for their needs but sometimes you may want to supply your user with the data in a form they can...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.