Single form, multiple databases

matt09524

Well-known member
Joined
Sep 14, 2005
Messages
47
Hi, I was wondering if this is even possible:

- Form1 has five selections.
- I have five seperate data bases

can I have each of those 5 selections on form1 open up form2 but pull from each individual database respectively? I have been going round and round about this in my head and cant some up with anything.

I am trying to avoid having to make a new form for each database I want to pull information from. Looking at my future with this projects, I could end up making a butt-ton of forms.
 
Im gonna answer my own question here, hopefully someone else can use this information:

You can pull from multiple access databases on the same form, but not dynamically. You would have to set up controls on the form for each database item being pulled. ie...

form1 --> control 1 is clicked.
form 2 pops up, and control 1 has the information you want.

you cannot click form 1 --> control 2 and have form 2 open up with control 1 being a different value. It seems you have to set the controls in form 1 statically to interact with the database that you set it to.

Now heres another question regarding access databases. I have only been able to show the first item in each field in an access database... I want to show as many items from each field as I need to on one form.

example: db1 has a field called years. Under this field, I have 4 records. I want label1 on form2 to show field 1, record 0 and label2 on form2 to show field 1, record 1. I cannot seem to do that. I am dragging items from the database viewer to the form by selecting the field as a label and dragging it. It will only show the first record in that field. how can I get all the rest of the records to be shown?

an even better question. Now that I have researched this a bit, it seems to me that I may not want to use an access database at all since there will be no user editing of this database. What I need is a way to call information outside the executable file and display it in a form. I dont need it in database form it seems as it is for informational purposes only. I would just put it in the form itself, but it is a literal series of novels worth of information. Any ideas as to what I can do with all this information??
 
Last edited by a moderator:
You can dynamically bind controls to databases.
By 5 different databases, do you mean 5 different tables? Or actual access mdb files?

I dont know how you are binding the data, but making some assumptions, you probably want to use a ContextManager to change the current row index of the dataset.

Now, if you do convert the data to a flat file format, consider using a csv format and loading the information into a dataset on startup to make it easy to search.

http://www.informit.com/articles/article.asp?p=26956&rl=1
http://www.vb-helper.com/howto_net_bound_controls.html

All the information you need on data binding can be found by googling bind database vb.net
 
Initially I meant 5 different mdb files. But now that I see what using the access db files ar e actually meant to be for, i realize now that an access database is not the way I need to go. I have no desire and make no plans for the users to pull up the information, manipulate it, and save it back to the db. I just want a db that will store what I put in there intially and leave it alone except to pull information up and display it in a form. Nevermind the fact that in a record in access, you can only have but so many characters in said record, which makes my need for access obsolete.

And this leaves me to only one real posibility that I can think of. Using a text file to store information in lines, have the form count all the lines, and assign each line to a string array and then have each control spit out the string array that I assign to it. But that leaves me with another issue. These text files will be able to be opened by the user, changed, saved and then the data inside program will look like whatever they want it to. I need a file, that will hold information securely, so that I can pull from it the fastest way possible but not be able to change it. Just pull, read, pull, read.... etc.

Thanks for those links though. They were quite informative and I marked them for future reference. If you have any ideas on paragraph 2, I would appreciate it :) I need to go figure out how to code a line counter and assigning lines to arrays :P
 
Wow. I actually think database tables are the way to go for you... but could you give us a bit more information about what your application is trying to do...? I think you need to take a little step back and think about what youre trying to achieve.
 
Ok basically, its a research tool. History to be specific. When the application opens, you have several catagories to choose from. It goes for a period of about 20 years and is a comprehensive timeline of events that could go as far as detailing day-to-day activites during that 20 year time span. Its broken down into 6 categories with each catergory having between 4 and 8 clickable controls.

Lets say you click one of the options... say... "The History of the world, the first 2 years" (not the actual topic... but an example.) When that form opens up, I need it to display the important years, dates of events, names of people (clickable to bring up bios) and an essay style write up of what went on during that period. I may bring need to bring up other information but that is beside the point...

Heres where my issue is.

Im not going to type all this into the form because that would make the executable too big. And I want to use the same form over and over again, I dont want to have 5,000 forms.

Access doesnt seem to be the way to go because as it seems to me, the only reason you would want to use access mdbs is so that the information can be read, modified and re-written to the database. I dont need and dont want the information changed. Putting aside all that, I need essays to be stored and access cannot hold that much information in one record.

pulling lines from a text file, now that I think about it, isnt really the way to go either because 1, the information is not secure. 2, I have to pull each line one at a time and that will cause me a ton more work and 3. that seems just... sloppy.

I am at ends with this because this is my first foray into making an application with such a large external data need that I just cant seem to think of a way to go with this. Ive never worked with SQL, and I dont think that I need to in this case because none of this information is being retreived from remote servers. It will be locally available saving the user from being dependant on the internet.

That is all .net express beta seems to offer for me in the way of external data extraction but none of it seems practical. Am I missing something here, or is this project at a stopping point?

I did realize, that if I found a way to use an external database i can set up form1 like this:

dim year1 as int
dim year2 as int
dim name1 as string
dim name2 as string
dim text1 and double

sub button 1
pulls year1 from data base and adds it as label 1
pulls name2 from database and adds it as label 2
...and so on and so forth for all the information for form2
form2.show()
end sub

and have a sub like that for each button on form1. each button takes the previously defined variables and assigns data to them from the appropriate database.
end sub

and so on and so forth
 
Last edited by a moderator:
You can def. put essays length data into Access databases, use the text field. This sounds like a big, no HUGE project though. Is this for school or work? We developed something simliar in house, and we used several developers and took 2 years to develop one for ourselves.

A database is def. the way to go from here, I think you should read a bit more about them. The basics are easy. And if youre developing a custom application to access the database, if you dont add the ability to update the data, then your data will be secure. Youll have to look at your resources and needs to choose between a SQL and a access database. I cant really help you without knowing more about the type and scope of the project (how many users will be using it, resources/budget available, length of development, etc).

It sounds like everything can go into the same database, (using multiple tables instead of databases), and youll be able to query the database with your form without a huge executable.

Also it sounds like this might be better as an ASP.NET project rather than a desktop application.
 
No, No, No, No, No.

This isnt a huge project, there is just a large amount of data.

If you put it in flat files, and the records were not of a fixed length you would have to load them into memory to query, which, based on the amount of data is a bad idea. You should keep them in a relational database format so that you can keep them in a file (yes, databases use files too), and query using sql.

Everytime you need to display a record(s), query the database, maybe save into an object and display it. Whats hard about that?

Give me some sample records and Ill make the application for you!
 
Wow guys, thanks for all the information. I did see that I can secure the files inside the dataset. So thanks for that. Now, when I tried to put 2 records in a field, I could only figure out how to get record 1 of each field to be displayed.....

So you know, this is a single person project that I am venturing on. I have no real budget except what I have to spend for research (historical) and software and then based on the end result of the project, marketing costs will be next but that will be based on demand. This is an idea I came up with and im kind of being pressured to continue this project. This is a single user application. No information will be downloaded from or sent to an internet database. Its local use only. Future upgrades may dictate that I add internet functionality, but based on where I plan on marketing this, that may be limited. I have no real time table for this except that prolonged time spent not working on it will quickly lessen my interest in making it. To let you know the budget I have, I am using express beta2 because I dont have the means to buy studio or just VB .net.. its pathetic.

anyways... after trial and error, I have built the beginning of the database, locked it, made a connection to it from vb, created the dataadapter and dataset. I have created the form and via a load button, I can load record 0 of each field onto the form in the way of labels and rich text boxes. Now.. as I said, I can only do this thus far with a load button. Can I automate this so that when the form is open it automatically puts that information up?

Also.... The way I did this was by clearing the text in the label, and set the databinding under the design view propertied to look at the database connection.mydbfile.table1.fieldname. This will only display the first record in the field. can you use the GUI control properties window to make another label just below the first one automatically incriment to record1, then record2 and so on? That is the last step I am in this data extraction crap that has been driving me nuts for the last 3 days.

And I do very much appreciate your patience with me. Like I said, this is my first venture into something this big.
 
Last edited by a moderator:
Back
Top