Access Database simple customer lookup app.

davidaperry69

Member
Joined
Feb 15, 2007
Messages
7
Programming Experience
Beginner
I am trying to write a very simple web application that can lookup a name in a simple access database that has about 500 records. I want to be able to type a name and then click on a lookup button and then the application can display the rest of the fields for that name. eg name, address, phone and email.

The access database only has four fields, name, address, phone number and email address. How do I do this. I recenlty took an ASP class online, and ASP has some built in forms like grid view that do everything anutomatically.

But that is for a web application, I need to write something in the regular Visual Studio.net. So that I can compile it and send it to other co-workers as an executable application.

I just downloaded Visual Studio and I setup a new form called form1 and I added a simple texbox for input of the name and a button called lookup.

Next I added a datagrid view box and connected it to my database to pull up the information for whichever name that is entered in the textbox. I am not sure if this is the best method, but I think I remember doing something simular when I took my VB class.

My Database is called DB1 and the table is called customers.
So now when I click on the button, I am not sure what code I need to write. Honestly I took a VB class almost 5 years ago. So forgot how to start writing the code for the button click event.

Any help will be appreciated. I wish I still had my old textbook.
 
Yes, you did..

I removed one redundant copy of the database, the BIN and OBJ folders and compacted the other database. The result is that I'm uploading your project back to you at 1/6th the size you sent me.. If you could take similar steps in future, im sure the people who pay for the forums bandwidth would appreciate it

I renamed your FillBy methods in the dataset: Youre supposed to give them a meaningful unique name when prompted
I didnt create a new query, I just changed the hyperion one and renamed it.
I added a table to the dataset to hold the distinct regions (you should consider a separate table in the db, with region code and descriptive text, its called normalisation and improves data integrity through use of foreign keying), and placed a combo bound to this on the form.
I added code to detect when the user changes the region they are looking at and commented this.
I also didnt bother with form 4..
 

Attachments

  • Hyperion Code Project.zip
    82.3 KB · Views: 31
VB.net project continued.

Are you sure you sent me the new file. I downloaded it and it looks the same as what I had. Also in form 4 that is the main one that I need help with. You said you did not bother with that one.

I need to stop the names from being repeated. vb.net does not let you add a new query. If you do you get an error message.

I was told by someone else that I should make a new table in the database. only for lookup purposes. But then how do I link the 2 tables together on the form? Why is it than ASP.net you do not have to do all of this stuff.
 
I downloaded the file Cjard attached and it was completely different to the one you uploaded.

If you read what he says, he has done everything that you asked for on Form 3, so Form 4 has become redundant.

Don't understand what you mean by
need to stop the names from being repeated. vb.net does not let you add a new query. If you do you get an error message

What names are you talking about? And you can add as many queries as you like to a TableAdapter!!!

Linking 2 tables together on a form - in your dataset create a datarelation. then in your dataSources tab you will see this relation and can pull across fields that you require from the relation.

I was told by someone else that I should make a new table in the database. only for lookup purposes.

We both told you this. And Cjard has done it for you in the project he uploaded for you.

Why is it than ASP.net you do not have to do all of this stuff
To quote Cjard on another thread, to answer your question;
VB.NET is a language, ASP.NET is a content delivery system.. Its like asking "which is better, the English language, or Television..?"

You can speak english on the phone, or on the television.. You dont have to speak english on either..
 
I need to stop the names from being repeated.

Well, type a new name when you get the chance to do so! I did (I actually renamed one of your existing ones too)
If you can rename Textbox1, then you can Rename FillBy in the same way.

vb.net does not let you add a new query. If you do you get an error message.
One of my table adapters has 37 queries.. All named nicely according to what they are for (they arent called FillBy1 ... FillBy37)

I was told by someone else that I should make a new table in the database. only for lookup purposes.
This can be sensible for blocks of data that dont change very often. It's called Normalising your data. For example the States of america dont change often.. FL is going to be FLorida for quite some time. By making it a separate lookup table you open yourself up to new possibilities of error checking and prevention..

But then how do I link the 2 tables together on the form?
With a relationship
(short, vague question = short, vague answer)

Why is it than ASP.net you do not have to do all of this stuff.
I dont know; I cant imagine it being so very different from a data access point of view..
 
To quote Cjard on another thread, to answer your question;

LMAO at this.. tell me, what are we going to do about your nick, when youre an oldbie and know everything! (Youre getting a good way there, see.. not so newbie now huh? :D)
 
lol tell me about it...couldn't think of a name when I joined last year and tbh didn't realise I would post as much as I have.

I've actually figured I learn as I answer posts...sometimes it actually helps me with what I'm trying to do in my own apps :D

...anyway of changing name? :eek:
 
David - I've been reading this thread because I'm having trouble with a dropdownlist recognizing the data from my access database - different issue - but I got caught up in this thread and had to make one point...

When you create a database - whether in Access or SQL or even DB2, you should NEVER have lots of redundant data (such as FL 20 times) in one table! This is a database construction issue - if you'd like some advice on creating databases check out this forum: http://www.microsoft.com/office/community/en-us/default.mspx?dg=microsoft.public.access.tablesdbdesign&lang=en&cr=US

It just might help you create a much more useful database and solve a few of your issues with the queries! I hope you got your problems solved, but IMO, you will continue to have issues if you don't construct a normalized db! Just my .02 cents,

Coleen
 
Coleen

Databases can be excessively normalised though.. If it gets to a point where you need more 7 joins just to generate the data you want, you probably have an over-normalisation issue :)
 
Back
Top