Perry,
Application.StartupPath gives you the location of the exe file. This is
where the database is assumed to be located if you don't say otherwise.
If your database is in a folder named Database that is a subfolder of the
folder where your exe file is located then you should be able to do this:
Data Source=Database\Database.mdb
Kerry Moorman
"Perry Langla" wrote:
What I am trying to do is get the directory information of the executing
assembly and insert this information into the ConnectionString. Here is an
example of what I have so far;
' I am using reflection to find the location of the exe file. This is
because the directory
'for the database is located in the same directory.
Dim Asm As System.Reflection.Assembly =
System.Reflection.Assembly.GetExecutingAssembly
Dim strEXELoc As String
strEXELoc = Asm.Location
' I am now putting the information into the string.
Dim strTemp As String
strTemp = strEXELoc
strTemp = System.IO.Path.GetDirectoryName(strEXELoc)
Dim DatabaseInfo As String
DatabaseInfo = strTemp
'
'OleDbConnection1
'
Me.OleDbConnection1.ConnectionString = "Jet OLEDB:Global Partial
Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database L" & _
"ocking Mode=1;Jet OLEDB:Database Password=;Data Source=""C:\Program
Files\Company" & _
"\Program\Database\Database.mdb"";Jet OLED" & _
"B:Engine Type=5;Provider=""Microsoft.Jet.OLEDB.4.0"";Jet
OLEDB:System database=;Je" & _
"t OLEDB:SFP=False;Jet OLEDB:Global Bulk Transactions=1;Mode=Share
Deny None;Jet " & _
"OLEDB:New Database Password=;Jet OLEDB:Create System
Database=False;Jet OLEDB:Do" & _
"n't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica
Repair=False;" & _
"User ID=Admin;Jet OLEDB:Encrypt Database=False"
I am trying to get the Data Source to read Data Source=""Default
Drive:\ExecutingAssembly Location\Database\Database.mdb""
Please help. I think I am on the right track.
Thanks Perry