Visual Basic Database

Does anybody have any simple databases that I could have to learn from? Perhaps a database that will work with a Access
File which could have basic features such as add,delete,next,previous,etc...  

I need to learn by example and most resources you go to only show small steps but never show you the whole picture.

Also, if you could recommend a newbie to some VB books that might have some good samples to learn from?
brewmanAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

brewmanAuthor Commented:
Edited text of question
0
ChrrrisCommented:
Is there any particular reason for wanting to use Visual Basic
rather than MS Access?
0
cymbolicCommented:
I hear you loud and clear.  With all the different methods and cursor types to choose from, it's really hard to get that first clear picture of how to manage databases in VB.  I found a good comprehensive review of the methods, including history of the Access database (Jet engine) to be "Hitchhiker's Guide to Visual Basic & SQL Server" by William R. Vaughn, published by Microsoft Press.

If you have VB installed, look at the VISDATA project in the Samples directory.  Also, go into your help system in VB, and start at the DBEngine help, then review Workspaces, then the dataBase object, then the recordset object, paying particular attention to the recordset object and it's example, and the different options for recordset cursor type specification, which determine whether you have an updateable recordset, which you need to use the .edti/.addnew/.update methods.  This is the heirarchy of the objects you need to work with to use the JET engine (or DAO) to process Access files (.MDB).

Problem is, it's not just the DAO methods you need to know, you also should become conversant in SQL to be able to use the .execute method.

If this doesn't get you where you want to be, I'll clip out some code examples.   A good sample is in the OPENDATABASE method:
Function UpdateNorthwind () As Integer
      Dim MyWorkspace As Workspace, MyDatabase As Database
      Dim MyTable As Recordset
      Dim MyFile As String
      Dim ErrorCondition As Integer
      UpdateDb = True

MyFile = "MYDB.MDB"      ' Define name of database.
      On Error GoTo DBErrorHandler      ' Enable error trapping.

Set MyWorkspace = Workspaces(0)
      ' Open database.
      Set MyDatabase = MyWorkspace.OpenDatabase(MyFile)
      If Not ErrorCondition Then
            On Error GoTo TableErrorHandler      ' Enable error trapping.
            ' Open table.
            Set MyTable = MyDatabase.OpenRecordset("Employees")
            If Not ErrorCondition Then
                  On Error GoTo EditErrorHandler      ' Enable error trapping.
                  Do Until MyTable.EOF
                        If MyTable![Title] = "Sales Representative" Then
                              MyTable.Edit      ' Enable editing.
                              MyTable![Title] = "Account Executive"   ' Make changes.

MyTable.Update      ' Save changes.
                        End If
                        MyTable.MoveNext      ' Move to next record.
                  Loop

MyTable.Close      ' Close table.

End If

MyDatabase.Close      ' Close database.

End If

On Error GoTo 0      ' Disable error trapping.

Exit Function
DBErrorHandler:
      ErrorCondition = True
      UpdateDb = False
      MsgBox "Can't open database.", vbExclamation
      Resume Next
TableErrorHandler:
      ErrorCondition = True
      UpdateDb = False
      MsgBox "Can't open Employees table.", vbExclamation
      Resume Next
EditErrorHandler:
      ErrorCondition = True
      UpdateDb = False
      MsgBox "Can't edit Employees table.", vbExclamation
      Resume Next
End Function

Although, I wouldn't recommend you use table processing if you are developing multiuser, shared applications, because you will be locking tables to do it.  Instead, use read only recordsets, then use execute methods to directly update individual records (but don't worry about this until you get something working).
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

brewmanAuthor Commented:
Thanks, you gave me alot to think about!  The reason I want to learn this VB is too eventually use this with Web Design in the future. Take care!
0
lmarceauCommented:
Imarceau,  Thanks for you input also...  You are right on the money!  I am sick of spending $$ for every new endevour I have.  I just got through with a phase of writing PERL scripts and spent about a total of 100$ in books..  I know that all my interests will eventually pay off.     I mostly do this as a hobby that hopefully someday will work with my Telecommunications work I am already involved with.     --Thanks...
0
brewmanAuthor Commented:
Don't get your heart set on really fast access (even in Access!) especially if you get into ODBC setups.  When (if) you do get to that point, using the trace log in your odbc setup information is a real eye opener regarding the volumes of ODBC transactions required to get a single resultset.

Also, if you are thinking about going to shared, multiuser applications, get the VB enterprise edition, and skip right over using DAO and Access databases.  You need to consider using something like Oracle or SQL server, and RDO as an access method.  Access and Jet just won't scale up to a real muliuser application.

Yeah, I know what you mean about the books.  Nothing's under $50 bucks, and you can't shoot a 30-30 through any of 'em!(but you want to)  I think I'm gettng tennis elbow just hauling 'em around! (I scan any book first at Barnes & Noble, because most of 'em turn out to be rehashed help system text!)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.