|
-
Mar 29th, 2008, 06:40 PM
#1
Thread Starter
Member
-
Mar 29th, 2008, 07:02 PM
#2
Re: Help with code or general advice pls
1. You want to be able to dynamically specify the location of the MDB. This means that you have your connection string, the only thing you'll be doing is setting the path to the MDB dynamically in your connection string by passing the string the OpenFileDialog's FileName property.
2. If you want your application to be scalable and robust and if you expect the application to grow over time, then nip the worm in the... cyst... and go for an enterprise level database server such as Oracle, SQL Server or MySql. In such a case, you won't be able to get the user to specify the 'location' of the database. It'll just have to be there ready to use. It would sit in one central location on the network.
-
Mar 29th, 2008, 07:03 PM
#3
Re: Help with code or general advice pls
Who would be you application audience?
In other words, for whom are you writing this program?
-
Mar 29th, 2008, 07:15 PM
#4
Thread Starter
Member
Re: Help with code or general advice pls
Firstly, Thankyou both for quick responses.
Mendhak: I'm not sure that this particular application would ever be used enough to justify the expense of cutting a bit of worm off , but i was hoping to learn more about SQL and perhaps ONE day, maybe even making a commercial app ??
Hack: It's a small project with only one or two users, (basically, excel spreadsheets are getting a chore for users), so wanted to use a database.
I have for want of a better word "straightened" up the data in the .xls and got it into access. thats looking good and dandy. What i wanted was to build an app that could be scaled up as needs require, rather than just make some impressive forms in Access. (it will also strengthen my coding skills.)
I've decided it's coding a "set data path to .mdb" button/form at runtime i need pls.
Thanks again
Last edited by robbie73; Mar 29th, 2008 at 07:34 PM.
-
Mar 29th, 2008, 07:23 PM
#5
Re: Help with code or general advice pls
Well, you can use MS Access for now, the essential coding skills that you want to improve - will improve whether you use this or something else. The only difference is that you're using a different namespace (System.Data.OleDb instead of System.Data.SqlClient) and you won't be using stored procedures as much (as you should).
One justification that you could possibly find is that if you have a whole bunch of applications, each one using a tiny database on its own, then that justifies buying SQL Server so that it can all be consolidated into one location under the control of a DBA. Management likes nothing more than a single point of failure dependent on a single person's whims and fancies.
-
Mar 29th, 2008, 07:55 PM
#6
Thread Starter
Member
Re: Help with code or general advice pls
LOL. thanks mendak.
erm could still use the help with setting the path in the connection string at runtime tho... ie some example code... pls??
-
Mar 29th, 2008, 08:41 PM
#7
Re: Help with code or general advice pls
Why would you need it set at runtime?
Are you planning on moving the database all over the place?
Put it in a network folder, and leave it there.
-
Mar 29th, 2008, 09:16 PM
#8
Thread Starter
Member
Re: Help with code or general advice pls
ok, so i "hard code" the db connection string into the app.
installer places the files(ie ,database, photos, linked docs templates for mailmerging etc) into a network drive. gr8
Then, out of the blue, the network dies on one machine due to lan issues (or some other minor hardware problem. can u see where i going with this.?
The user obviously can't UPDATE the MAIN database, (don't want two people updating two diff db's..it stands to reason.)
BUT copying the db and files locally (using a usb drive or other such media) would give the poor end user with network issues the ability to at least VIEW recent data, thus enabling to carry out a days work or whatever without tons of questions flying back and forth to the colleague, thus stressing the colleague too...... and thats why....well, one example of why,... I dont want to "hard code" the path to the database.
(and please can somebody help with the code to dynamically select a path to DB, because that is what i really want )
-
Mar 30th, 2008, 12:59 PM
#9
Re: Help with code or general advice pls
Fair enough, here's what you do. Hardcode your connection string in the code, but concatenate it. For example,
Code:
Dim MDBPath As String = "C:\test.mdb"
Dim ConnString As String = Provider=Microsoft.Jet.OLEDB.4.0;Data Source=##MDBPath##;User Id=admin;Password=;
ConnString = ConnString.Replace("##MDBPath##",MDBPath)
See what I did there? You can therefore get MDBPath from an OpenFileDialog if you want, anywhere.
-
Mar 30th, 2008, 01:54 PM
#10
Thread Starter
Member
-
Mar 30th, 2008, 04:48 PM
#11
Re: Help with code or general advice pls
I generally store the location (Path) to the mdb in a config file (config.ini) saved in the applications folder. That way the network share name can be what ever the user want it to be. On initial startup of the app on a machine I have the user browse to the database (mdb file) location and store it in a var and write it to the ini file. On subsequent startups I read the ini file and test if I can find the database there if I can I open the app and continue. If the mdb has been moved I have the user browse to the new location save it and continue startup.
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Apr 1st, 2008, 08:43 AM
#12
Re: Help with code or general advice pls
Ah, good. But, but, but... you can now use Application Settings if you have VS 2005.
http://msdn2.microsoft.com/en-us/lib...xh(VS.80).aspx
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|