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 March 3rd, 2009, 09:27 PM
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 Trouble with Time Tracker project

On Chapter 7 of Beginning visual basic 2005 Databases, I am working from page 136 to 145. I developed the queries as directed on pages 137 & 138. I inserted the code for working with Group Queries as shown form pages 139 to 144. When I tried to run the program and insert a group as directed in step 11 on page 144, I got an error message "Too few parameters. Expected 1". I compared the code I entered with the code listed in the book and there is no difference. I also compared the queries used in the program. They are the same.

I even went back and deleted the code entries and copied in the sections from the code containted in the downloads. Still get the same reesults.

I am using Visual Studio 2005. By the way, I bakced up the program into another file and converted it to Visual Studio 2008. Got the same results.

Did anybody else run into the problem?

Greenbriar
 
Old March 5th, 2009, 07:16 AM
Thearon's Avatar
Wrox Author
 
Join Date: Dec 2003
Posts: 396
Thanks: 0
Thanked 8 Times in 8 Posts
Default

Please post your insert query and the code that calls the insert query.

Thearon
 
Old March 5th, 2009, 05:24 PM
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 Trouble with Time Tracker project

Theoron:

Here is the Insert Query (usp_InsertGroujp):
INSERT INTO Groups ( GroupID, GroupName, GroupDescription, LastJUpdateDate )
VALUES ([@GroupID], [@GroupName], [@GroupDescription], Daste( ) + Time( ));

The code calling it:

Code:
 
    Private Sub ActionAdd()
        'Initialize a new instance of the data access base class
        Using objData As New WDABase
            Try
                'Add database row based on the active screen
                Select Case strActiveScreen
                    Case "Projects"
                        'Set the SQL strng
                        objData.SQL = "usp_InsertProject"
                        'Initialize the Command object
                        objData.InitializeCommand()
                        'Add the Parameters to the Parameers collection
                        objData.AddParameter("@ProjectId", _
                            Data.OleDb.OleDbType.Guid, 16, Guid.NewGuid())
                        objData.AddParameter("@ProjectName", _
                            Data.OleDb.OleDbType.VarChar, 50, txtProjectName.Text)
                        objData.AddParameter("@ProjectDescription", _
                            Data.OleDb.OleDbType.LongVarChar, _
                            txtProjectDescription.Text.Length, _
                            txtProjectDescription.Text)
                        objData.AddParameter("@SequenceNumber", _
                        Data.OleDb.OleDbType.UnsignedTinyInt, 1, _
                        CType(txtSequenceNumber.Text, Byte))
                        'Open the database connection
                        objData.OpenConnection()
                        'Execute the query
                        intRowsAffected = objData.Command.ExecuteNonQuery()
                        'Close the database connection
                        objData.CloseConnection()
                        If intRowsAffected = 0 Then
                            Throw New Exception("Insert project Failed")
                        End If
                        'Clear the input fields
                        txtProjectName.Text = String.Empty
                        txtProjectDescription.Text = String.Empty
                        txtSequenceNumber.Text = String.Empty
                        'Reload the Projects list
                        LoadProjects()
                    Case "Groups"
                        'Set the SQL string
                        objData.SQL = "usp_InsertGroup"
                        'Initialize the Command object
                        objData.InitializeCommand()
                        'Add the Parameters to the Parameters collection
                        objData.AddParameter("@GroupID", _
                            Data.OleDb.OleDbType.Guid, 16, Guid.NewGuid())
                        objData.AddParameter("@GroupName", _
                            Data.OleDb.OleDbType.VarChar, 50, txtGroupName.Text)
                        objData.AddParameter("@GroupDescription", _
                            Data.OleDb.OleDbType.LongVarChar, _
                            txtGroupDescription.Text.Length, _
                            txtGroupDescription.Text)
                        'Open the database connection
                        objData.OpenConnection()
                        'Execute the query
                        intRowsAffected = objData.Command.ExecuteNonQuery()
                        'Close the database connection
                        objData.CloseConnection()
                        If intRowsAffected = 0 Then
                            Throw New Exception("Insert Group Failed")
                        End If
                        'Clear the input fields
                        txtGroupName.Text = String.Empty
                        txtGroupDescription.Text = String.Empty
                        'Reload the Groups list
                        LoadGroups()
                    Case "Group Projects"
                    Case "Roles"
                    Case "Users"
                End Select
                'Display a message that the record was added
                ToolStripStatus.Text = "Record Added"
            Catch ExceptionErr As Exception
                MessageBox.Show(ExceptionErr.Message, strAppTitle)
            End Try
        End Using
    End Sub
Hope this is enoght to help resolve he issue.

Greenbriar
 
Old March 7th, 2009, 09:01 AM
Thearon's Avatar
Wrox Author
 
Join Date: Dec 2003
Posts: 396
Thanks: 0
Thanked 8 Times in 8 Posts
Default

Greenbriar,

The last field name in your query is specified as "LastJUpdateDate". Is this the name you have defined in the Groups table of the database?

Thearon
 
Old March 7th, 2009, 09:24 PM
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 Trouble with Time Tracker project

Theoron:

Tnx for helping me with the problem. I have to admit I'm embarassed at not finding the cause of the problem myself. I felt the cause was in the query but I did not see the misprint in the field name even though I reviewed that query at least five or six times. Should have reverted to a practice I had for many years regarding progamming. Many years ago, I was in a group that was introducing computer controlled component tests in Naval Industrial activities. At first we were making slow progress because of programming mistakes and the time it took to locate and correct them. The group came up with the policy that if you wrote the program and could not locate the mistake within a half hour after being shut down, you took the program to another group member for review. The reviewer would go thtough the program steps and usually find the mistake within an hour. This included errors in sequence, spelling or outright wrong process calls. I'm going to write that into the cover of my programming books as a reminder.

Greenbriar
 
Old March 27th, 2009, 09:18 AM
Registered User
 
Join Date: Mar 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default problem with the timetracker project

Thearon,
I am having the same problem as Greenbriar, when I run the program it gives me the following error "Too few parameters. Expected 1", I have checked the code several times and I see everything ok, here is the code:


INSERT INTO Groups ( GroupID, GroupName, GroupDescription, LastUpdateDate )
VALUES ([@GroupID], [@GroupName], [@GroupDescription], Date()+Time());


Private Sub ActionAdd()
'Initialize a new instance of the data access base class
Using objData As New WDABase
Try
'Add database row based on the active screen
Select Case strActiveScreen
Case "Projects"
'Set the SQL string
objData.SQL = "usp_InsertProject"
'Initialize the Command object
objData.InitializeCommand()
'Add the Parameters to the Parameters collection
objData.AddParameter("@ProjectID", _
Data.OleDb.OleDbType.Guid, 16, Guid.NewGuid())
objData.AddParameter("@ProjectName", _
Data.OleDb.OleDbType.VarChar, 50, txtProjectName.Text)
objData.AddParameter("@ProjectDescription", _
Data.OleDb.OleDbType.LongVarChar, _
txtProjectDescription.Text.Length, _
txtProjectDescription.Text)
objData.AddParameter("@SequenceNumber", _
Data.OleDb.OleDbType.UnsignedTinyInt, 1, _
CType(txtSequenceNumber.Text, Byte))
'Open the database connection
objData.OpenConnection()
'Execute the query
intRowsAffected = objData.Command.ExecuteNonQuery()
'Close the database connection
objData.CloseConnection()
If intRowsAffected = 0 Then
Throw New Exception("Insert Project Failed")
End If
'Clear the input fields
txtProjectName.Text = String.Empty
txtProjectDescription.Text = String.Empty
txtSequenceNumber.Text = String.Empty
'Reload the Projects list
LoadProjects()

Case "Groups"
'Set the SQL string
objData.SQL = "usp_InsertGroup"
'Initialize the Command object
objData.InitializeCommand()
'Add the Parameters to the Parameters collection
objData.AddParameter("@GroupID", _
Data.OleDb.OleDbType.Guid, 16, Guid.NewGuid())
objData.AddParameter("@GroupName", _
Data.OleDb.OleDbType.VarChar, 50, txtGroupName.Text)
objData.AddParameter("@GroupDescription", _
Data.OleDb.OleDbType.LongVarChar, _
txtGroupDescription.Text.Length, _
txtGroupDescription.Text)
'Open the database connection
objData.OpenConnection()
'Execute the query
intRowsAffected = objData.Command.ExecuteNonQuery()
'Close the database connection
objData.CloseConnection()
If intRowsAffected = 0 Then
Throw New Exception("Insert Group Failed")
End If
'Clear the input fields
txtGroupName.Text = String.Empty
txtGroupDescription.Text = String.Empty
'Reload the Groups list
LoadGroups()

Case "Group Projects"
Case "Roles"
Case "Users"
End Select
'Display a message that the record was added
ToolStripStatus.Text = "Record Added"
Catch ExceptionErr As Exception
MessageBox.Show(ExceptionErr.Message, strAppTitle)
End Try
End Using
End Sub
 
Old March 28th, 2009, 07:09 AM
Thearon's Avatar
Wrox Author
 
Join Date: Dec 2003
Posts: 396
Thanks: 0
Thanked 8 Times in 8 Posts
Default

Everything on the surface appears to be correct. May I suggest that you open Access and run the query there. This will prompt you for each input parameter and will also tell you the parameters name. You can compare the parameter names with those that you specified in your code.

Thearon





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem in project time tracker greenbriar BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 2 February 23rd, 2009 09:16 PM
Error Creating Project Time Tracker Database flashmanTom SQL Language 0 January 15th, 2008 04:09 PM
Problem with creating SQL Project Time Tracker Jim Dean BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 5 August 31st, 2006 12:23 PM
Chap 12 Project tracker - listboxes don't clear trancelife BOOK: Beginning Access 2003 VBA 1 February 14th, 2005 12:15 PM
trouble creating package for project omb Pro VB 6 4 August 14th, 2003 08:38 AM





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