Link to home
Start Free TrialLog in
Avatar of sramkris
sramkris

asked on

Two dimensional arrays!!!!

Hey Experts,

I have a table which has a list of locations and for each location i need to capture the Company and Sponsor information like name address phone and fax. I have a form which has the drop down which lists the location and 10 text boxes to accept the contact information. for each of the location the form has to accept all the contact information and save all the information at the same time. I was trying to use the 2 dimesional array to capture all the contact information and save them to the database but was not able to figure out how to do it..

Any ideas will help me a great deal..

Thanks
-Ram
Avatar of monkesdb
monkesdb
Flag of United Kingdom of Great Britain and Northern Ireland image

It's usually benaficial to create Classes which define all the information and are linked like in the database.

Use the Class Builder Utility, it makes it simple. Then you can create a collection based on that class. so you create a class called Client and a collection called Clients and then use that to save the data from the database.
Avatar of sramkris
sramkris

ASKER

THanks for the comment
I have very little idea as how to get it done so if you have any example or code base which i can look at it will be very helpful.
The db structure is all not that good and basically i want to complete the data entry of what the user is entered so i was thinking more in terms of arrays to get the job done...

If you have any eg for either case it will help me a great deal to get this one done

Thanks
Ram...

Ok..just to confirm what you want to do...

User selects a location from the list box..and then enters the contact details like name, address..etc using these 10 textboxes... right?

Now how is your database designed.. i mean..have you a table for Location  and one for Contact or.. do you have only one table?

NExt question... what database have you got ...is it sql server or ms access...or anything else.?


I guess the easiest way to do this is to

1. Get location which user selects from list
2. Read whatever details user has entered in the textboxes
3. Just Pass these data from textboxes as parameters and insert them in your database..(i.e no need to use 2-d arrays)

Now how you insert these data for each location in your tables depend on how your tables are designed!!!

Maybe you could give us some more information here!!






Hey Lichien

You got most of it right. The user selects a location and then enters data in the text boxes and he can select the next one and enter data in all the text boxes. All this is stored in a table called contact. I have a table called location and it has PK loc_id and it is a FK in the contact table. The contact table has loc_id and cont_id as PK in this table. I have a Sybase database and i am using MS Access and VB Automation to write data to this table. I agree with your idea that i need 2 d arrays but i have not used 2 d arrays before so i have no idea how to get this done!! Any help is highly appreciated.

Thanks
Ram


ASKER CERTIFIED SOLUTION
Avatar of Lichien
Lichien

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Lichien

I guess i missed the point totally. Actually i was interested in using the 2D  arrays because when the user is doing data entry he can enter data for 3 locations at the same time and before commiting the data to the db he can change any data for any location and then save it. So i was thinking if he needs to see the data before the save is done then the data has to be stored in a array and show the user the values at the change of the value in the location drop down.
Now after seeing your ideas i feel i can add the record to the db and populate the record back from the db when the user selects the location and update the record everytime.
Will that make the process slow cause i am going back and forth with the data....?????
I also did not need any code in sybase..I am more interested in the knowing how to do it in VB.. I will run through your code in vb and then let you know or may be if you remember anything which needs to be added in th code which you have written let me know and i will use it to see if it works using a 2D arrays.
Now i am more interested in knowing how it is done using a 2d array.

Thanks for all your help
Ram\
Actually its better to send multiple small requests to the server ...than sending one big chunk....

I dont think its going to make the process slower... and anyhow... after the user has entered info for a location..you can get him to click on a Save button...and then just prompt him that he wants to save the details.

The problem with using arrays is that... for example.. basic scenario....user enters details for 10 locations.. computer crashes... that means he has to do the whole thing again..i.e enter details for 10 locations again..because the array exists only in memory

Doing it the way i suggested... user has to enter details for 10 locations... he does the first one.. program prompts him to confirm..data get written to database.. he carries on like this for each location..  while entering the details for the 9th... computer crashes (dunno why ..:-)  ...in this case... he's at least got 8 records saved..so he just need to enter for the 9th and 10th location..  this itself should convince you!!

Concerning the codes for the 2darray..I think I've given you the skeleton ...so that you get an idea... I guess...you just have to try it..and see..

Good luck