RE: OleDbConnection String Help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?S2VycnkgTW9vcm1hbg==?=

    RE: OleDbConnection String Help

    Perry,

    Application.Sta rtupPath 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 ConnectionStrin g. 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.Reflecti on.Assembly =
    System.Reflecti on.Assembly.Get ExecutingAssemb ly
    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. GetDirectoryNam e(strEXELoc)
    >
    Dim DatabaseInfo As String
    DatabaseInfo = strTemp
    >
    >
    '
    'OleDbConnectio n1
    '
    Me.OleDbConnect ion1.Connection String = "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:\Pro gram
    Files\Company" & _
    "\Program\Datab ase\Database.md b"";Jet OLED" & _
    "B:Engine Type=5;Provider =""Microsoft.Je t.OLEDB.4.0"";J et
    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;J et 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=""Defaul t
    Drive:\Executin gAssembly Location\Databa se\Database.mdb ""
    >
    >
    Please help. I think I am on the right track.
    >
    Thanks Perry
    >
  • Perry Langla

    #2
    Re: OleDbConnection String Help

    Thanks Kerry
    The solution works.
    Sometimes I over analize things.



    "Kerry Moorman" <KerryMoorman@d iscussions.micr osoft.comwrote in message
    news:656E1F75-95DA-489D-B793-56A46B8282C4@mi crosoft.com...
    Perry,
    >
    Application.Sta rtupPath 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 ConnectionStrin g. 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.Reflecti on.Assembly =
    >System.Reflect ion.Assembly.Ge tExecutingAssem bly
    > 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. GetDirectoryNam e(strEXELoc)
    >>
    > Dim DatabaseInfo As String
    > DatabaseInfo = strTemp
    >>
    >>
    >'
    > 'OleDbConnectio n1
    > '
    > Me.OleDbConnect ion1.Connection String = "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:\Pr ogram
    >Files\Compan y" & _
    > "\Program\Datab ase\Database.md b"";Jet OLED" & _
    > "B:Engine Type=5;Provider =""Microsoft.Je t.OLEDB.4.0"";J et
    >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;J et 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=""Defaul t
    >Drive:\Executi ngAssembly Location\Databa se\Database.mdb ""
    >>
    >>
    >Please help. I think I am on the right track.
    >>
    >Thanks Perry
    >>

    Comment

    Working...