|
-
Jun 27th, 2008, 12:03 AM
#1
Thread Starter
Addicted Member
[RESOLVED] What does this means?
Whenever I am trying to add in new data in my form, I ge this windows pop-up; It states that 'Too few parameters, Expected 5.'
What does this means and also which it is referring to?
By the way, I input data for name, description, quantity no and price, these 4 sections...
-
Jun 27th, 2008, 12:08 AM
#2
Hyperactive Member
Re: What does this means?
let me see your code and what version are you using?
-
Jun 27th, 2008, 12:19 AM
#3
Re: What does this means?
Without any code we can only guess and guess badly 
Sounds like you are not supplying the proper requested/required number of fields/parameters to completely insert the record.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 27th, 2008, 12:43 AM
#4
Thread Starter
Addicted Member
Re: What does this means?
This is for the case of selecting
Code:
Case "Groups"
objData.SQL = "usp_InsertGroup"
objData.InitializeCommand()
objData.AddParameter("@OrderID", _
Data.OleDb.OleDbType.Guid, 16, Guid.NewGuid())
objData.AddParameter("@OrderName", _
Data.OleDb.OleDbType.VarChar, 50, txtGroupName.Text)
objData.AddParameter("@OrderDescription", _
Data.OleDb.OleDbType.LongVarChar, _
txtGroupDescription.Text.Length, _
txtGroupDescription.Text)
objData.OpenConnection()
intRowsAffected = objData.Command.ExecuteNonQuery()
objData.CloseConnection()
If intRowsAffected = 0 Then
Throw New Exception("Insert Group Failed")
End If
txtGroupName.Text = String.Empty
txtGroupDescription.Text = String.Empty
LoadGroups()
This is the code og the loadgroups
Code:
Private Sub LoadGroups()
Dim objListViewItem As ListViewItem
Using objData As New WDABase
Try
cboUserGroup.DataSource = Nothing
cboUserGroup.DisplayMember = String.Empty
cboUserGroup.ValueMember = String.Empty
objData.SQL = "usp_SelectGroups"
objGroupsDS = New DataSet
objData.FillDataSet(objGroupsDS, "Groups")
lvwGroups.Items.Clear()
For intIndex = 0 To objGroupsDS.Tables("Groups").Rows.Count - 1
objListViewItem = New ListViewItem
objListViewItem.Text = _
objGroupsDS.Tables("Groups").Rows(intIndex).Item( _
"OrderName")
objListViewItem.Tag = _
objGroupsDS.Tables("Groups").Rows(intIndex).Item( _
"OrderID")
objListViewItem.SubItems.Add( _
objGroupsDS.Tables("Groups").Rows(intIndex).Item( _
"OrderDescription"))
objListViewItem.SubItems.Add( _
Format(objGroupsDS.Tables("Groups").Rows(intIndex).Item( _
"LastUpdateDate"), "g"))
lvwGroups.Items.Add(objListViewItem)
Next
cboUserGroup.DataSource = objGroupsDS.Tables("Groups")
cboUserGroup.DisplayMember = "OrderName"
cboUserGroup.ValueMember = "OrderID"
cboUserGroup.SelectedIndex = -1
Catch ExceptionErr As Exception
MessageBox.Show(ExceptionErr.Message, strAppTitle)
End Try
End Using
objListViewItem = Nothing
End Sub
Private Sub lvwGroups_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles lvwGroups.Click
Using objData As New WDABase
Try
objData.SQL = "usp_SelectGroup"
objData.InitializeCommand()
objData.AddParameter("@OrderID", Data.OleDb.OleDbType.Guid, 16, _
lvwGroups.SelectedItems.Item(0).Tag)
objData.OpenConnection()
objData.DataReader = objData.Command.ExecuteReader
If objData.DataReader.HasRows Then
objData.DataReader.Read()
txtGroupID.Text = _
objData.DataReader.Item("OrderID").ToString.ToUpper
txtGroupName.Text = _
objData.DataReader.Item("OrderName")
txtGroupDescription.Text = _
objData.DataReader.Item("OrderDescription")
txtGroupUpdateDate.Text = _
Format(objData.DataReader.Item("LastUpdateDate"), "g")
End If
objData.DataReader.Close()
objData.CloseConnection()
Catch ExceptionErr As Exception
MessageBox.Show(ExceptionErr.Message, strAppTitle)
End Try
End Using
End Sub
Erm, will this be enough? Do you still need any more info? My file or something?
Last edited by melvados; Jun 27th, 2008 at 12:47 AM.
-
Jun 27th, 2008, 12:49 AM
#5
Hyperactive Member
Re: What does this means?
have you tried debugging your code to find out what line the error is on? that would help me to help you.
-
Jun 27th, 2008, 01:02 AM
#6
Re: What does this means?
The answer to this is pretty simple. The error message speaks for itself. The sproc you're executing expects 5 parameters. Nowhere in that code do you add 5 parameters to a command.
-
Jun 27th, 2008, 02:33 AM
#7
Thread Starter
Addicted Member
Re: What does this means?
hmm.. what is parameter actually?
-
Jun 27th, 2008, 03:18 AM
#8
Re: What does this means?
 Originally Posted by melvados
hmm.. what is parameter actually?
Hmmm... I wonder...
Code:
Case "Groups"
objData.SQL = "usp_InsertGroup"
objData.InitializeCommand()
objData.AddParameter("@OrderID", _
Data.OleDb.OleDbType.Guid, 16, Guid.NewGuid())
objData.AddParameter("@OrderName", _
Data.OleDb.OleDbType.VarChar, 50, txtGroupName.Text)
objData.AddParameter("@OrderDescription", _
Data.OleDb.OleDbType.LongVarChar, _
txtGroupDescription.Text.Length, _
txtGroupDescription.Text)
objData.OpenConnection()
intRowsAffected = objData.Command.ExecuteNonQuery()
objData.CloseConnection()
If intRowsAffected = 0 Then
Throw New Exception("Insert Group Failed")
End If
txtGroupName.Text = String.Empty
txtGroupDescription.Text = String.Empty
LoadGroups()
-
Jun 27th, 2008, 03:22 AM
#9
Thread Starter
Addicted Member
Re: What does this means?
Well, I mean the exact term if it actually have. Because in the quote, given the fact that I did put 'addparameter' and that I still have the error of 'Too few parameters. expecpected 5', which is why I am kinda confused now.... T_T
-
Jun 27th, 2008, 03:26 AM
#10
Re: What does this means?
I'm not sure what's to be confused about. The error message says that 5 parameters are expected. You're calling AddParameter 3 times. 3 is not equal to 5.
-
Jun 27th, 2008, 06:22 AM
#11
Frenzied Member
Re: What does this means?
Aren't you missing the parameters for "quantity no and price", they would be the other 2 parameters.
-
Jun 27th, 2008, 05:02 PM
#12
Re: What does this means?
Yes, and in your stored procedure "usp_InsertGroup" you can look to see its parameters declared for input will have 5. So when you call the sp you need to pass 5 parameters as mentioned.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 2nd, 2008, 08:03 PM
#13
Thread Starter
Addicted Member
Re: What does this means?
have resolved the above problem. Thanks alot.
Anyway had a question to ask, in some books I have seen the author writing some codes that has 'And Not' stuff...
What does the Not means? As the book did not show wat it means...
-
Jul 2nd, 2008, 08:53 PM
#14
Re: What does this means?
 Originally Posted by melvados
have resolved the above problem. Thanks alot.
Anyway had a question to ask, in some books I have seen the author writing some codes that has 'And Not' stuff...
What does the Not means? As the book did not show wat it means...
This question is unrelated to the topic of this thread and so it should have been asked in a new thread of its own. Please do so in future.
The 'Not' key word reverses a Boolean value. Not True is equal to False and Not False is equal to True. It basically allows you to check whether something is not true, i.e. that it's false. For instance:
vb.net Code:
If Not myCheckBox.Checked Then
'The check box is not checked.
End If
-
Jul 2nd, 2008, 10:31 PM
#15
Hyperactive Member
Re: What does this means?
i know it is unrelated to the topic but why do you use not true when you can just check to see if it is false or not false when you could check if it is true?
-
Jul 2nd, 2008, 10:47 PM
#16
Re: What does this means?
 Originally Posted by bagstoper
i know it is unrelated to the topic but why do you use not true when you can just check to see if it is false or not false when you could check if it is true?
Using 'Not' is more succinct, and more natural, than comparing one Boolean value to another Boolean value to get a third Boolean value. Tell me which of these sentences sounds more logical.
1.
If you are not a member of VBForums you cannot post questions.
2.
If you are a member of VBForums is false then you cannot post questions.
If you speak it one way then why choose to code it the other?
Also, 'Not' is useful for toggling Boolean values. You could do this:
vb.net Code:
If someValue Then
someValue = False
Else
someValue = True
End If
but I'd much rather do this:
vb.net Code:
someValue = Not someValue
-
Jul 2nd, 2008, 10:58 PM
#17
Re: What does this means?
 Originally Posted by bagstoper
i know it is unrelated to the topic but why do you use not true when you can just check to see if it is false or not false when you could check if it is true?
I think I may have misunderstood your question, and you have misunderstood what I originally said. The 'If' statement does one thing: it tests a Boolean expression and, if that expression evaluates to True, an action is executed. You can only test for True using an If statement, so what do you do if you specifically want to know if an expression is False? You negate the expression. If expression X evaluates to False then Not X evaluates to True. You can then use an If statement to test whether Not X evaluates to True, in which case you know that X evaluates to False, which is what you wanted to know in the first place.
-
Jul 2nd, 2008, 11:55 PM
#18
Hyperactive Member
Re: [RESOLVED] What does this means?
thanks that makes a lot of sense when explained that way.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|