views:

80

answers:

2

Over 6 years ago I did visual basic programming. I used VB6 for an editor. I did it for a semester in college, and I didnt make a good grade. Since then I have been doing other things in life. However I was asked at work to create a web application. I am creating my application in vb.net 2003. I began desigining the interface of the web form. I have 5 forms, all of them need to connect to a database which I already have prepared. I created the database in MS Access. If I can get one of the forms to look at the database, I think I can get the rest of them to do it. I have tried using beginner tutorials online and I am not finding anything thats helpful. The closest tutorial I have found that could atleast give me an idea of what to do, the code doesnt work, I did everything to the 'T'. http://www.startvbdotnet.com/ado/msaccess.aspx

Is there anyone out there that can help me?

+3  A: 

What you are looking for to access Microsoft Accesss Databases (MDB) is the Microsoft JET Client. If you are using a Visual Studio here is the VB for simple access. You can query the database file with SQL.

Outside class

   Imports System.Data.OleDb
   Imports System.Data

Inside class, to access the database

    Dim cn As OleDbConnection
    Dim db As OleDbDataAdapter
    cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\folder\file.mdb;")
    cn.Open()
    db = New OleDbDataAdapter("select * from Table1", cn)

    Dim ds As New DataSet()
    db.Fill(ds)

    For Each row As DataRow In ds.Tables(0).Rows
        me.txtRow1.text = row("Row1")
        me.txtRow2.text = row("Row2")
        me.txtRow3.text = row("Row3")
    Next

    cn.Close()
    cn.Dispose()
    cn = Nothing

For more information go to, http://en.wikipedia.org/wiki/Microsoft_Jet_Database_Engine . Hope it helps!

Justin
Oh you will need these import lines above the class defination of the page. "Imports System.Data.OleDb", "Imports System.Data"
Justin
You can also use the OleDbCommand object to write info to the database.
Justin
Here at work we have a SQL server. At the moment my boss has been swamped with many things and hasnt set me up with access to it.
Larry_at_KCCHelpdesk
oops, I didnt know hitting enter would do that. anyway....I am creating a form to bring up building permit information for the past 10 years and to be able to add new information. I have several other forms for various db for this agency. The building permits form also has to do some calculations. but my biggest problem is getting the form to connect. Is it hard to take the database in access and convert it over to SQL?
Larry_at_KCCHelpdesk
Nop, you can export the Access database into a CSV file and import. Google it, it is real simple.
Justin
A: 

A 'low barrier to entry' of using an Access DB with VB.Net would be to import the ADODB COM library. Since you've done VB6 before, you should be familiar with the "classic" ADO syntax.

I'm using it right now with a small VB.Net 2008 app and it works perfectly fine. No need to deal with data connections, adapters, fill methods, data sets, or data tables.

voon