 |
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
|
|
|
|

March 3rd, 2009, 09:27 PM
|
|
Authorized User
|
|
Join Date: Jul 2007
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

March 5th, 2009, 07:16 AM
|
 |
Wrox Author
|
|
Join Date: Dec 2003
Posts: 396
Thanks: 0
Thanked 8 Times in 8 Posts
|
|
Please post your insert query and the code that calls the insert query.
Thearon
|
|

March 5th, 2009, 05:24 PM
|
|
Authorized User
|
|
Join Date: Jul 2007
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

March 7th, 2009, 09:01 AM
|
 |
Wrox Author
|
|
Join Date: Dec 2003
Posts: 396
Thanks: 0
Thanked 8 Times in 8 Posts
|
|
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
|
|

March 7th, 2009, 09:24 PM
|
|
Authorized User
|
|
Join Date: Jul 2007
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

March 27th, 2009, 09:18 AM
|
|
Registered User
|
|
Join Date: Mar 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

March 28th, 2009, 07:09 AM
|
 |
Wrox Author
|
|
Join Date: Dec 2003
Posts: 396
Thanks: 0
Thanked 8 Times in 8 Posts
|
|
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
|
|
 |