Wrox Programmer Forums
|
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 18th, 2003, 11:26 AM
Registered User
 
Join Date: Jul 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default VB Form & Database

Hi, I'm a beginner to VB and Databases but have some very basic knowledge. Here's the problem:

I would like to create a form (in VB) that i can use to read/write/edit fields in a database.

I'll explain what i want which may be easier.

Say for example i want to create a form with a list of my computers in a drop down list (or the like) then i can add my computers to the database, and then i want to be able to add upgrades, dates, and prices for each upgrade done for each computer and store them in the database. I don't know if there are any easier ways, but the method is not important to me as long as i can have a very simple to use form with the fields to add the computer names to it then i can add/delete/edit the various upgrades done on what date and the price, then be able to display them back in chronological order.

does that make sense?
i tried my best to explain, i would greatly appreciate it if somebody could please e-mail me with a detailed explanation on how _exactly_ i can do this or guide me to a specific tutorial with the same basic function as this. thank you very much for any help.

-=-=-=-=-=-=-=-=-=-
LordBeholdeR
 
Old July 19th, 2003, 03:45 AM
Registered User
 
Join Date: Jul 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

For VB 6, I've been using the following steps to set up access to my database:
First, you need to add the ADO components to your VB project as follows:


Part one: Set up your project
1. Go to the Project menu - select Components:
2. Add the Microsoft ADO Data Control 6.0
3. Add any other ADO controls you might want to use - the data grid control, combo boxes, etc.
4. You drop the ADO control onto a form. The text should read ADODC in the control when you drop it on the page.
To set up the connection to the database:


Part 2: Set up your Database or DSN connection
Then you have to set up the connection to the database. You can build a connection string, or use a DSN. To build a string (I have not used the DSN steps) you should click on the ADO control that you have dropped on the form, and in the properties window, click
1. Connection string...
2. Then select "Use connection string" and click Build.
3. Select the type of data source. For access it would be Jet and Click Next.
4. Browse to select the database (I think you have to create this first. I've never done it any other way. You can use the visual data manager, or just create the tables in your dbms of choice, i.e. access or sql server)
5. Fill in the admin name and password (or just keep the defaults to set a blank password).
6. Click Test connection to make sure you can open the connection.

Part 3: Select your recordsource

Now that you have set up your connection to the database, click on the ADO control again and select the recordsource. That's the table or SQL query you want to use as the source for your form. Whereas the ADODC references the database, this step connects you to the specific rows you need to use.

After you get all that done, then you can build sql queries, or just reference tables by using the various data controls such as the combo box control, etc.

You can use a SQL query and order by date, so that your computer stuff is sorted in chronological order.

Hope that helps to get you started.

Rachel

Quote:
quote:Originally posted by LordBeholder
 Hi, I'm a beginner to VB and Databases but have some very basic knowledge. Here's the problem:

I would like to create a form (in VB) that i can use to read/write/edit fields in a database.

I'll explain what i want which may be easier.

Say for example i want to create a form with a list of my computers in a drop down list (or the like) then i can add my computers to the database, and then i want to be able to add upgrades, dates, and prices for each upgrade done for each computer and store them in the database. I don't know if there are any easier ways, but the method is not important to me as long as i can have a very simple to use form with the fields to add the computer names to it then i can add/delete/edit the various upgrades done on what date and the price, then be able to display them back in chronological order.

does that make sense?
i tried my best to explain, i would greatly appreciate it if somebody could please e-mail me with a detailed explanation on how _exactly_ i can do this or guide me to a specific tutorial with the same basic function as this. thank you very much for any help.

-=-=-=-=-=-=-=-=-=-
LordBeholdeR
 
Old July 19th, 2003, 08:34 AM
Registered User
 
Join Date: Jul 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you very much for your help, i really appreciate it.

Like i said i am a beginner to VB, you might as well assume zero knowledge.

I managed to make it as far as Test conection by ignoring the references to SQL because i have no clue as to what that is.

I don't know what I should do with the data grid control or combo boxes once I add them either.I added the ADODC control as you saidd and sed it up, but now I'm completely stuck. I added the Microsoft Data Grid Control 6, I assume that's the grid that you meant?

I'll check the help files and see what I can find out, but I doubt it is going help thatm much. Do you know where I can get some good free tutorials? I don't have money to buy books or anything I'm afraid. Thank you again

-=-=-=-=-=-=-=-=-=-
LordBeholdeR
 
Old July 19th, 2003, 08:44 AM
Authorized User
 
Join Date: Jun 2003
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I suggest that you purchase the book Beginning Visual Basic 6 Database Programming by John Connell (ISBN 1-861001-06-1). This book is designed and written with the assumption you spoke of - zero knowledge - and will answer a lot of questions you have.

Kenny Alligood
 
Old July 19th, 2003, 09:10 AM
Registered User
 
Join Date: Jul 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for the suggestion, i will certainly buy it IF i get any money.

-=-=-=-=-=-=-=-=-=-
LordBeholdeR
 
Old May 17th, 2004, 12:13 PM
Registered User
 
Join Date: Jul 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I gave up on this about 9 months ago because I didn't understand it. Today I was searching google and found my own post that I had forgotten I had placed. Well after having read it again I have just given it a go and it all makes perfect sense. I have now finally created my database and form for it and it works. I just need to learn how to add a few other things to it and I'm happy. Thanks for that help all that time ago that is helping me now. Thanks!!!!!

-=-=-=-=-=-=-=-=-=-
LordBeholdeR





Similar Threads
Thread Thread Starter Forum Replies Last Post
how to set a form as startup form in vb.net 2.0 mallikalapati .NET Framework 2.0 1 February 21st, 2008 09:19 AM
Urgent VB form Migration to VB.net form kvenkat_2k1 Pro VB.NET 2002/2003 1 December 7th, 2005 04:58 PM
Database Insert/Update problem with VB.NET form tino mclaren VB Databases Basics 2 February 4th, 2005 05:12 AM
Linux & KDE & C++ & QT & MYSQL & Kdevelop Munnnki Linux 0 January 2nd, 2005 05:41 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.