Connecting VB .net to Access DB

cpopham
03-09-2004, 01:11 PM
Okay, I need a good tutorial or something. This is what I have (it is more a pratice database for learning on) I have an Access XP relational database. It has 5 tables. The tables are listed as follows:
Months -(No relation, used for a combo box)
CompanyName -related to the address(one to many), contact (one to many), orders (one to many) tables with a key
Address - related as listed above
Contact - related as listed above
Orders - as listed above

Okay I have a form in access for the person to enter all of the information: company name, address(s), contact person(s) and then on this main form is a subform for the orders placed by this company.

You can search with a button by the various fields on the form. Like if the company is placing an order you can pull up this form then just press the new order button to enter a new order.

This is what I would like to learn to do with VB .NET.

I want to take this form and make it into a stand alone .Net form that just connects to these tables. I want the form to have the same ability as the Access Database form. Where you can enter a new company, find a company, scroll the company's find a company and place an order for them, etc.

So is there a good tutorial on this or can someone explain and help me along the way?

I am basically wanting to make a VB .Net Windows form that looks like the Access form and will do what the Access form will do through a connection to the DB.

Thanks a lot.

Chester

MikeJ
03-09-2004, 04:15 PM
Well, this will require ADO.Net. In VB, ADO was an interesting being, as it was harder to bind data to a particular control. However, with .Net, we have a new set of tools for making a nice data form for .Net.

Look up the DataSet, DataProvider, and DataAdapter in MSDN, they will help. But here's a simple way to make a quick connection to a DB:


Create a form with the textboxes and other things that look like your access form.
Drag an OleDbDataAdapter control from the Data tab on the Toolbox.
On the second page of the wizard, on the Provider tab, click Microsoft.Jet 4.0 OLE DB Provider.
Re-click the Connection tab, and fill in the data.
Now add your SQL statement (or use the Query Builder).
Goto Data > Generate DataSet, and call it something that you can remember. (I used dsMyDataSet)
Use the table from your OleDbDataAdapter.
Click each 'field' on your form that you will show the data in, and click (Data Bindings) in the properties window.
For the Text property, click and navigate until it will show the field you want.
Finally, to make it work, include this in Form_Load:

'This makes stuff show up.
OleDbDataAdapter1.Fill(dsMyDataSet)

This is a really quick way to do it, but its the fastest way without getting deep into theory. If you want to check out the 'deep' methods, look up ADO.Net in the MSDN reference.

cpopham
03-14-2004, 02:05 PM
I have been very busy and have not gotten back to this yet. Our professor has now changed our curriculum and said that we will study ADO .NET and databinding for the last three days of class.

Chester

amir_syafrudin
03-14-2004, 07:04 PM
A suggestion ... if I may ...

IMHO ...

You might want to focus on database updating and databinding. The reply from MikeJ really helps you know, but you might need to connect and bind programmatically.

It's true VS.Net can generate the connection, dataadapter, dataset, and ease the databinding; just like MikeJ explains. But when you alter your database, you need to do all the steps again (well, that's the straight forward way at least). If you can identify the changes you need to do, you can directly alter your code without doing the steps again.

Things I suggest you should emphasize when studying ADO .Net and databinding:
1. BindingManagerBase and CurrencyManager.
2. Ways to update a database: using OleDbCommand or the Update method of a dataadapter.

Any other suggestions?

Your fellow newbie ... if you are a newbie :)

cpopham
03-15-2004, 07:13 AM
Yes from what I have reading some methods allow for easier changes than others.

Chester

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum