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

Setting the ConnectionString at StartUp

Hi everyone,

How would I adjust the following ConnectionString to point to the
applications installed path?
===
Provider=Microsoft.Jet.OLEDB.4.0;Password="";User ID=Admin;Data Source=SOME
DRIVE\SOME DIRECTORY\THE DATABASE;Mode=Share Deny None;Extended
Properties="";Jet OLEDB:System database="";Jet OLEDB:Registry Path="";Jet
OLEDB:Database Password="";Jet OLEDB:Engine Type=5;Jet OLEDB:Database
Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk
Transactions=1;Jet OLEDB:New Database Password="";Jet OLEDB:Create System
Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale
on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet
OLEDB:SFP=False
===

I want the user to be able to install the application wherever they want,
and I need the ConnectionString to point to that location.
I have no problem getting the Application.StartupPath.
I have tried to split the ConnectionString into two seperate strings and
concatenate the strings and Application.Path together, but it doesn't seem
to work.

This is what I have tried...
It seems to mess up the DoubleQuotes in the strings.

///
Dim AppPath As String = Application.StartupPath

Dim conString1 As String =
"Provider=Microsoft.Jet.OLEDB.4.0;Password=""; User ID=Admin;Data Source="

Dim conString2 As String = "\THE DATABASE;Mode=Share Deny None;Extended
Properties="";Jet OLEDB:System database="";Jet OLEDB:Registry Path="";Jet
OLEDB:Database Password="";Jet OLEDB:Engine Type=5;Jet OLEDB:Database
Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk
Transactions=1;Jet OLEDB:New Database Password="";Jet OLEDB:Create System
Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale
on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet
OLEDB:SFP=False"

Dim conString As String = conString1 & AppPath & conString2
///

Thanks in advance,

Gary
Nov 20 '05 #1
4 2021
Try using reflection

I believe its System.Reflection.Assembly.GetExecutingAssembly.Lo cation

That is the full path and file name of the executing assembly (your
application in this case)

Try looking at the other "Get" methods in the assembly class.

-Rick

"Didymus" <di************@hotmail.com> wrote in message
news:#z**************@TK2MSFTNGP09.phx.gbl...
Hi everyone,

How would I adjust the following ConnectionString to point to the
applications installed path?
===
Provider=Microsoft.Jet.OLEDB.4.0;Password="";User ID=Admin;Data Source=SOME DRIVE\SOME DIRECTORY\THE DATABASE;Mode=Share Deny None;Extended
Properties="";Jet OLEDB:System database="";Jet OLEDB:Registry Path="";Jet
OLEDB:Database Password="";Jet OLEDB:Engine Type=5;Jet OLEDB:Database
Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk
Transactions=1;Jet OLEDB:New Database Password="";Jet OLEDB:Create System
Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet
OLEDB:SFP=False
===

I want the user to be able to install the application wherever they want,
and I need the ConnectionString to point to that location.
I have no problem getting the Application.StartupPath.
I have tried to split the ConnectionString into two seperate strings and
concatenate the strings and Application.Path together, but it doesn't seem
to work.

This is what I have tried...
It seems to mess up the DoubleQuotes in the strings.

///
Dim AppPath As String = Application.StartupPath

Dim conString1 As String =
"Provider=Microsoft.Jet.OLEDB.4.0;Password=""; User ID=Admin;Data Source="

Dim conString2 As String = "\THE DATABASE;Mode=Share Deny None;Extended
Properties="";Jet OLEDB:System database="";Jet OLEDB:Registry Path="";Jet
OLEDB:Database Password="";Jet OLEDB:Engine Type=5;Jet OLEDB:Database
Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk
Transactions=1;Jet OLEDB:New Database Password="";Jet OLEDB:Create System
Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet
OLEDB:SFP=False"

Dim conString As String = conString1 & AppPath & conString2
///

Thanks in advance,

Gary

Nov 20 '05 #2
Thanks,

But...
System.Reflection.Assembly.GetExecutingAssembly.Lo cation
.... gives "C:\Some Folder\Some Other Folder\etc\Application.exe"

....
Application.StartupPath
.... gives "C:\Some Folder\Some Other Folder\etc\"
which is what I want.

My trouble is joining the Strings together...

String1 and String2 have some values with two double quotations ("") in
them.
When I declare the two strings...
....Public String1 As String = "Some text string with "" in it\"
....Public String2 As String = "Some other string with "" in it"
.... AppPath As String = Application.StartupPath
.... String3 = String1 & AppPath & String2

I get... String3 = "Some text string with " in it\C:\Some Folder\Some Other
Folder\etc\Some other string with " in it"

Notice that the double quotes get reduced to one single quote (").

If I remove the portions with the double quotes, it works fine, however, I
may need the double quotes at a later time.

Thanks,

Gary
Nov 20 '05 #3
> My trouble is joining the Strings together...


Gary,

If you need to add a double quote to the string, try using (chr)34.

Charlie
Nov 20 '05 #4
Thanks Charlie,

I knew it would be something silly, just couldn't put my finger on it...
lol

Gary
Nov 20 '05 #5

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

Similar topics

6
by: Johan Louwers | last post by:
I have a qustion. I have to set a JAVA_HOME variable on a Solaris9 system... what kind of a variable? A system-defined.../....a user defined.../.....???? and how do I set this so java can...
11
by: Zlatko Matiæ | last post by:
Hello. I have a MS Access front-end working with PostgreSQL database. I have successfully created saved File DSN. My paa-through queries are referring to that file as well as linked tables. But I...
10
by: johndoe | last post by:
While creating a shopping cart application I noticed a strange bug which resulted in the Constructor and everything being called twice. I was using Inherited classes ClassShowProducts inherited...
0
by: Nate Hekman | last post by:
I'm trying to set up a Membership/Role Provider for an ASP.NET 2.0 beta 2 site using SqlMembershipProvider, and am having problems configuring SQL Server. I'm comfortable with ASP.NET but very...
2
by: Phil Campaigne | last post by:
Hello, I am trying to use the linux startup script in the contrib directory of the distribution. I get the following error in the server log: LOG: invalid secondary checkpoint record PANIC: ...
0
by: Jonathan Wood | last post by:
I seem to be having errors creating and accessing an SQL database. Unfortunatley, I am brand new to SQL setup and administration issues so this really is not my area of expertise. I know I had...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
4
by: =?Utf-8?B?QmlsbCBNaWxk?= | last post by:
Feel free to let me know if there is a better place to post this question I'm a website developer trying to write a Windows Service, and I think I'm running into trouble due to the paradigm...
1
by: =?Utf-8?B?UmljaA==?= | last post by:
In the Registry at HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Jet \ 4.0 \ Engines \ Text the default key for Text Format is: "Format" = "CSVDelimited" I can use the following OleDB...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.