simple question/correction

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • muddasirmunir
    Contributor
    • Jan 2007
    • 284

    simple question/correction

    i am using the following code for opening the connection

    Code:
    con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\graph\Sales.mdb;Persist Security Info=False"
    it work fine but only when i place a database on D:\graph\Sales. mdb
    i want that it should work even i install my project on any directory or in any folder.

    i know there is somting i had to use APP PATH\sales.mdb insted of D:\graph\Sales. mdb which can solve this but i just forget
    it and not getting the correct code
  • jamesd0142
    Contributor
    • Sep 2007
    • 471

    #2
    Originally posted by muddasirmunir
    i am using the following code for opening the connection

    Code:
    con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\graph\Sales.mdb;Persist Security Info=False"
    it work fine but only when i place a database on D:\graph\Sales. mdb
    i want that it should work even i install my project on any directory or in any folder.

    i know there is somting i had to use APP PATH\sales.mdb insted of D:\graph\Sales. mdb which can solve this but i just forget
    it and not getting the correct code
    application.sta rtuppath & "\databasen ame"

    Comment

    • mafaisal
      New Member
      • Sep 2007
      • 142

      #3
      Hi,

      Try This


      in Vb6

      Code:
      dim DataPath as string
      DataPah = app.path & "\Sales.mdb"
      con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & DataPath & ";Persist Security Info=False"
      In .net2005


      Code:
      dim DataPath as string = System.Environment.CurrentDirectory & "\Sales.mdb"
      Faisal

      Comment

      • muddasirmunir
        Contributor
        • Jan 2007
        • 284

        #4
        Thanks .

        Originally posted by mafaisal
        Hi,

        Try This


        in Vb6

        Code:
        dim DataPath as string
        DataPah = app.path & "\Sales.mdb"
        con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & DataPath & ";Persist Security Info=False"
        In .net2005


        Code:
         
        dim DataPath as string = System.Environment.CurrentDirectory & "\Sales.mdb"
        Faisal
        Last edited by Killer42; Feb 21 '08, 01:55 AM. Reason: Fixed broken QUOTE tag.

        Comment

        • mafaisal
          New Member
          • Sep 2007
          • 142

          #5
          Hello,

          Always welcome

          Faisal

          Originally posted by muddasirmunir
          Thanks
          Last edited by Killer42; Feb 21 '08, 01:56 AM. Reason: Fixed broken quote block (and reduced size)

          Comment

          Working...