Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

adding a database to a setup project -- part two

Status
Not open for further replies.

pinkwho

Programmer
May 7, 2002
10
0
0
US
I have a project in VB.Net (VS 2003) that I have added a setup project to. Everything works great on the development PC. I am putting the database in my project as well as in the application folder in the set up project. When I try to run the application (setup runs flawlessly both on the development and test machine) on the test machine however it is still looking for the database in the original path where the database was stored on the development machine (and of course this directory doesn't exist, infact the PROFILE (WINXP) doesn't even exist). If I manually create the path and put the mdb in the correct folder, the program runs flawlessly. My question is, how can I tell my program to look for the DB in the "c:\program files\some company\some program" directory for the mdb?? Any help is appreciated. Thanks - btw this community rocks...

See thread: thread796-1205333

I thank all of you for your replies, in order from last to first:

PR: The db needs to be local per machine, it's an imported excel doc with vital info.

CHIP: I get what you are saying and but I would like to keep it encapsulated.

LNB: Understood and noted although I'd like something a little ... cleaner if you know what i mean.

TipG: I really like where you are headed.

That said, perhaps I didn't give enough info. I would like to do Tip's suggestion, however perhaps I didn't give enough info; I am using an OleDbDataAdapter, an OleDbConnection, and a dataset generated from that. I am not writing an SQL statement. that said would it be possible to put the path in using these controls, or will I have to start using an SQL statement? I have everything finished and I am venturing into new territory, I don't have problems with SQL or coding it... it's coding it in .NET that I have VERY little experience in.
 
I dont think that there is any problem. Try something like the following.
Code:
        Dim cnstr As String = "....; Data Source=""" & Application.StartupPath & "\yourDBname.mdb"""
        Dim cn As New OleDb.OleDbConnection(cnstr)
        cn.Open()

[COLOR=green]        ' Rest code[/color]

        cn.Close()
        cn.Dispose()

All you need, adapter, command, etc is in System.Data.OleDb.
The datatable to fill, using the System.Data.OleDb.OleDbDataAdapter.Fill or anything else query of yours, is: dim dt as new system.data.datatable
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top