Wrox Programmer Forums
BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5
This is the forum to discuss the Wrox book Beginning Visual Basic 2005 Databases by Thearon Willis; ISBN: 9780764588945
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 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 April 29th, 2008, 12:27 AM
Authorized User
Points: 68, Level: 1
Points: 68, Level: 1 Points: 68, Level: 1 Points: 68, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jul 2007
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default hand code for datasets


I'm working with an ACCESS database I originally built with Access 97 and programmed with Visual Basic 4 designed to keep track of the amateur radio contacts I made over the last nineteen years. The database contains nearly 3200 entries. Last year I changed the format to ACCESS 2007 and now want to code it with VB 2005. I'm having trouble devleoping datasets and need help. I prefer to hand code the routines and have used Chapters 5 and 6 of "Beginning Visual Basic 2005 Databases" to develop the sub routine. The routine I use is:
 Private Sub frmContactsShow_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        'Establish a connection string
        Dim strConnectionString As String = _
        "Provider =Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=..:\ktplog.mdb;"
        Dim objConnection As New OleDbConnection(strConnectionString)
        ' Get the Query statement
        storedSQL = lblHidden.Text
        'Declare and initialize a new instance of the OleDbCommand class
        Dim objCommand As New OleDbCommand(storedSQL, objConnection)
        'Declare an OleDbDataAdapter obDject
        Dim objDataAdapter As New OleDbDataAdapter(objCommand)
        'Declare a Datatable object
        Dim objDataTable As New DataTable

        'Set the SelectCommand for the OleDbDataAdapter
        objDataAdapter.SelectCommand = objCommand

        'Populate the DataTable

        'Bind the DataTable to the DataGridView
        grdSelectedContacts.DataSource = objDataTable

        'Set the SelectionMode property
        grdSelectedContacts.SelectionMode = DataGridViewSelectionMode.FullRowSelect

        'Catch OleDbException As OleDbException
        'MessageBox.Show(OleDbException.Message, "N7KTP Contact Log Error")

The objCommand "StoredSQL" is a query passed from the previous screen using the lblHidden.Text property to perform the pass.
The query reads 'StoredSQL = "SELECT * FROM ContLog WHERE ContLog.Station LIKE '%" & Me.txtCallSignIn.Text & "%';"

My problem is that I get an OleDbException "Not a Valid File name"
when the progam reaches the line "objDataAdapter.Fill(objDataTable)" is executed. can you review my programming and tell me what I need to do to correct the problem?

Your book has helped me to grasp the new techniques of visual basic but I wish you wrote more examples of hand coating to help me do more hand coating which I feel more comfortable with.


Old May 1st, 2008, 05:42 AM
Thearon's Avatar
Wrox Author
Join Date: Dec 2003
Posts: 396
Thanks: 0
Thanked 8 Times in 8 Posts


From your error message it sounds like perhaps your connection string is not correct. In fact this code does not look correct: Data Source=..:\ktplog.mdb;. Get rid of the semicolon in this code. Next, ensure your database is one folder above your executable file as indicated in your data source or move the database into the bin folder with your executable and just specify the database name.


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to integrate a hand-held bar code scanner suneet.pant Pro VB.NET 2002/2003 4 March 4th, 2008 06:06 AM
Hand Coding VS Data Wizards Bulldog BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 3 May 22nd, 2007 04:21 AM
'hand' is undefined crmpicco Javascript How-To 3 March 10th, 2005 10:43 AM
Use Hand Held Scanner Mahavishnu Classic ASP Professional 1 November 16th, 2004 12:50 PM

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