Results 1 to 9 of 9

Thread: [RESOLVED] Database Location

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2006
    Posts
    27

    Resolved [RESOLVED] Database Location

    Hi All,

    I wrote a VB6 program wherein I am storing a number of public variables in a very simple access database. My questions:

    1. Once I distribute the program, how can I tell the program where the Access program is located in the end user's computer if I don't know in which directory the user installed Access.

    2. What happens if the user does not have Access in their computer and my program calls Access? Will my program crash?

    I appreciate your help.
    Ace

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Database Location

    The answers to both of your questions could be very simple, but I'm afraid you havent given us enough information.

    How are you connecting to the database? (eg: ADO code, DAO code, Data Control).

    What code are you using (or if you are using a Data Control, what properties have you set)?

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jul 2006
    Posts
    27

    Re: Database Location

    Quote Originally Posted by si_the_geek
    The answers to both of your questions could be very simple, but I'm afraid you havent given us enough information.

    How are you connecting to the database? (eg: ADO code, DAO code, Data Control).

    What code are you using (or if you are using a Data Control, what properties have you set)?

    Well right now, I only created the database but have not connected to it yet. I intend on using a data control though. The only reason I am using a database is so I can use crystal reports to create a report based on the user's data (I understand that is the easiest way to use Crystal). After the report is created, I would like the program to delete the data from the database because the information need not be saved.

    I guess I'm just looking for something simple to make sure my program finds the end user's Access program and doesn't crash.

    I really appreciate your help.
    Ace

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Database Location

    Data controls are far from ideal, and will cause problems for at least one of your questions - see here for an explanation of why bound controls are bad.

    I would recommend using ADO code instead (see the ADO Tutorial link in my signature for an example).

    If you use that, your first question is solved by simply putting the path of the database into your connection string (probably using App.Path - which is the same folder as your program), and your second question is solved by installing MDAC (link below).

  5. #5
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: Database Location

    Quote Originally Posted by AceFlyer
    The only reason I am using a database is so I can use crystal reports to create a report based on the user's data (I understand that is the easiest way to use Crystal).
    I find the easiest way is to create a disconnected (not connected to any database) ADO recordset and send that recordset to Crystal, regardless of whether the recordset gets filled from a database, a text file, user input or anything else.
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Jul 2006
    Posts
    27

    Re: Database Location

    Quote Originally Posted by Al42
    I find the easiest way is to create a disconnected (not connected to any database) ADO recordset and send that recordset to Crystal, regardless of whether the recordset gets filled from a database, a text file, user input or anything else.

    Thank you all for the great replies. I'll get to work and I'm sure with your suggestions, it will work.

    Thanks Again....
    Ace

  7. #7
    Addicted Member GenocideOwl's Avatar
    Join Date
    Jul 2006
    Location
    Ohio
    Posts
    144

    Re: [RESOLVED] Database Location

    simply putting the path of the database into your connection string (probably using App.Path - which is the same folder as your program)
    so how would I actually input that? right now it looks like this
    VB Code:
    1. cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    2.     "Data Source= C:\Documents and Settings\Owner\My Documents\BB\Congo VB\db1.mdb"

    so how would I use the "App.Path"?
    thanks

  8. #8
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: [RESOLVED] Database Location

    By using simple string manipulation.
    VB Code:
    1. cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    2.     "Data Source=[u]" & App.Path & "[/u]\db1.mdb"

  9. #9
    Addicted Member GenocideOwl's Avatar
    Join Date
    Jul 2006
    Location
    Ohio
    Posts
    144

    Re: [RESOLVED] Database Location

    thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width