Results 1 to 18 of 18

Thread: [RESOLVED] What does this means?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2008
    Posts
    232

    Resolved [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...

  2. #2
    Hyperactive Member
    Join Date
    Feb 2007
    Location
    indiana
    Posts
    341

    Re: What does this means?

    let me see your code and what version are you using?

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    May 2008
    Posts
    232

    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.

  5. #5
    Hyperactive Member
    Join Date
    Feb 2007
    Location
    indiana
    Posts
    341

    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.

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    May 2008
    Posts
    232

    Re: What does this means?

    hmm.. what is parameter actually?

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: What does this means?

    Quote 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()
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    May 2008
    Posts
    232

    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

  10. #10
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  11. #11
    Frenzied Member CoachBarker's Avatar
    Join Date
    Aug 2007
    Location
    Central NY State
    Posts
    1,121

    Re: What does this means?

    Aren't you missing the parameters for "quantity no and price", they would be the other 2 parameters.
    Thanks
    CoachBarker

    Code Bank Contribution
    Login/Manage Users/Navigate Records
    VB.Net | C#

    Helpful Links: VB.net Tutorial | C Sharp Tutorial | SQL Basics

  12. #12
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  13. #13

    Thread Starter
    Addicted Member
    Join Date
    May 2008
    Posts
    232

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

  14. #14
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: What does this means?

    Quote 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:
    1. If Not myCheckBox.Checked Then
    2.     'The check box is not checked.
    3. End If
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  15. #15
    Hyperactive Member
    Join Date
    Feb 2007
    Location
    indiana
    Posts
    341

    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?

  16. #16
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: What does this means?

    Quote 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:
    1. If someValue Then
    2.     someValue = False
    3. Else
    4.     someValue = True
    5. End If
    but I'd much rather do this:
    vb.net Code:
    1. someValue = Not someValue
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  17. #17
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: What does this means?

    Quote 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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  18. #18
    Hyperactive Member
    Join Date
    Feb 2007
    Location
    indiana
    Posts
    341

    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
  •  



Click Here to Expand Forum to Full Width