Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. TOO Many argumnets error

TOO Many argumnets error

Scheduled Pinned Locked Moved Visual Basic
csharphelp
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    soniasan
    wrote on last edited by
    #1

    #Region "Insert record into Outbound_Login_Details table with AgentId,login time and other details" Public Sub INSERT_AGENT_DETAILS() Try con.Open() Command.CommandText = "usp_Outbound_Login_Details" Command.CommandType = CommandType.StoredProcedure Command.Parameters.Add("@Agent_ID", SqlDbType.BigInt).Value = AgentID Command.Parameters.Add("@Extno", SqlDbType.VarChar, 50).Value = g_Extension_Number Command.Parameters.Add("@Outbound_Login_id", SqlDbType.BigInt) Command.Parameters("@Outbound_Login_id").Direction = ParameterDirection.Output dataReader = Command.ExecuteReader() g_OutBound_Login_ID = CInt(Command.Parameters("@OutBound_Login_ID").Value) 'Command.ExecuteNonQuery() ' Catch ex As Exception lblerror1.Text = ex.Message Finally dataReader.Close() con.Close() End Try End Sub #End Region **************** CREATE PROCEDURE usp_Outbound_Login_Details ( @Agent_ID BIGINT , @Extno VARCHAR(50), @IPAddress VARCHAR(50) = 0 ) AS BEGIN SET NOCOUNT ON DECLARE @LoginDateTime AS DATETIME SET @LoginDateTime = GETDATE() INSERT INTO Outbound_Login_Details WITH (ROWLOCK) ( Agent_ID , Login_Time , ExtNo,IPAddress ) VALUES ( @Agent_ID , @LoginDateTime , @ExtNo,@IPAddress ) SELECT Outbound_Login_ID FROM Outbound_Login_Details (NOLOCK) WHERE Agent_ID = @Agent_ID AND Login_Time = @LoginDateTime AND Extno = @ExtNo END GO this vb.net code gives me ex.Message = "Procedure or function usp_Outbound_Login_Details has too many arguments specified." Please what wrong in vb.net code.....

    C D V 3 Replies Last reply
    0
    • S soniasan

      #Region "Insert record into Outbound_Login_Details table with AgentId,login time and other details" Public Sub INSERT_AGENT_DETAILS() Try con.Open() Command.CommandText = "usp_Outbound_Login_Details" Command.CommandType = CommandType.StoredProcedure Command.Parameters.Add("@Agent_ID", SqlDbType.BigInt).Value = AgentID Command.Parameters.Add("@Extno", SqlDbType.VarChar, 50).Value = g_Extension_Number Command.Parameters.Add("@Outbound_Login_id", SqlDbType.BigInt) Command.Parameters("@Outbound_Login_id").Direction = ParameterDirection.Output dataReader = Command.ExecuteReader() g_OutBound_Login_ID = CInt(Command.Parameters("@OutBound_Login_ID").Value) 'Command.ExecuteNonQuery() ' Catch ex As Exception lblerror1.Text = ex.Message Finally dataReader.Close() con.Close() End Try End Sub #End Region **************** CREATE PROCEDURE usp_Outbound_Login_Details ( @Agent_ID BIGINT , @Extno VARCHAR(50), @IPAddress VARCHAR(50) = 0 ) AS BEGIN SET NOCOUNT ON DECLARE @LoginDateTime AS DATETIME SET @LoginDateTime = GETDATE() INSERT INTO Outbound_Login_Details WITH (ROWLOCK) ( Agent_ID , Login_Time , ExtNo,IPAddress ) VALUES ( @Agent_ID , @LoginDateTime , @ExtNo,@IPAddress ) SELECT Outbound_Login_ID FROM Outbound_Login_Details (NOLOCK) WHERE Agent_ID = @Agent_ID AND Login_Time = @LoginDateTime AND Extno = @ExtNo END GO this vb.net code gives me ex.Message = "Procedure or function usp_Outbound_Login_Details has too many arguments specified." Please what wrong in vb.net code.....

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      Your Command object is likely a field on the class. Every time you call the method INSERT_AGENT_DETAILS() you add more parameters to the Command. So, it will fail the second, and subsequent time, the method is called.

      Upcoming FREE developer events: * Developer Day Scotland Recent blog posts: * Different ways to add point data in SQL Server 2008 * Spatial References in SQL Server 2008 My website |

      1 Reply Last reply
      0
      • S soniasan

        #Region "Insert record into Outbound_Login_Details table with AgentId,login time and other details" Public Sub INSERT_AGENT_DETAILS() Try con.Open() Command.CommandText = "usp_Outbound_Login_Details" Command.CommandType = CommandType.StoredProcedure Command.Parameters.Add("@Agent_ID", SqlDbType.BigInt).Value = AgentID Command.Parameters.Add("@Extno", SqlDbType.VarChar, 50).Value = g_Extension_Number Command.Parameters.Add("@Outbound_Login_id", SqlDbType.BigInt) Command.Parameters("@Outbound_Login_id").Direction = ParameterDirection.Output dataReader = Command.ExecuteReader() g_OutBound_Login_ID = CInt(Command.Parameters("@OutBound_Login_ID").Value) 'Command.ExecuteNonQuery() ' Catch ex As Exception lblerror1.Text = ex.Message Finally dataReader.Close() con.Close() End Try End Sub #End Region **************** CREATE PROCEDURE usp_Outbound_Login_Details ( @Agent_ID BIGINT , @Extno VARCHAR(50), @IPAddress VARCHAR(50) = 0 ) AS BEGIN SET NOCOUNT ON DECLARE @LoginDateTime AS DATETIME SET @LoginDateTime = GETDATE() INSERT INTO Outbound_Login_Details WITH (ROWLOCK) ( Agent_ID , Login_Time , ExtNo,IPAddress ) VALUES ( @Agent_ID , @LoginDateTime , @ExtNo,@IPAddress ) SELECT Outbound_Login_ID FROM Outbound_Login_Details (NOLOCK) WHERE Agent_ID = @Agent_ID AND Login_Time = @LoginDateTime AND Extno = @ExtNo END GO this vb.net code gives me ex.Message = "Procedure or function usp_Outbound_Login_Details has too many arguments specified." Please what wrong in vb.net code.....

        D Offline
        D Offline
        Dave Kreskowiak
        wrote on last edited by
        #3

        Simple. You didn't specify all the parameters for the SQL Procedure, plus you added one that isn't in the parameter list for it. This is the list of parameters your SQL Proc is expecting:

        @Agent_ID BIGINT ,
        @Extno VARCHAR(50),
        @IPAddress VARCHAR(50) = 0

        You gave it these parameters:

        @Agent_ID
        @Extno
        @Outbound_Login_id

        The proc doesn't return any values in a "@Outbound_Login_Id" parameter. It returns a table with a single column called "Outbound_Login_ID".

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007

        1 Reply Last reply
        0
        • S soniasan

          #Region "Insert record into Outbound_Login_Details table with AgentId,login time and other details" Public Sub INSERT_AGENT_DETAILS() Try con.Open() Command.CommandText = "usp_Outbound_Login_Details" Command.CommandType = CommandType.StoredProcedure Command.Parameters.Add("@Agent_ID", SqlDbType.BigInt).Value = AgentID Command.Parameters.Add("@Extno", SqlDbType.VarChar, 50).Value = g_Extension_Number Command.Parameters.Add("@Outbound_Login_id", SqlDbType.BigInt) Command.Parameters("@Outbound_Login_id").Direction = ParameterDirection.Output dataReader = Command.ExecuteReader() g_OutBound_Login_ID = CInt(Command.Parameters("@OutBound_Login_ID").Value) 'Command.ExecuteNonQuery() ' Catch ex As Exception lblerror1.Text = ex.Message Finally dataReader.Close() con.Close() End Try End Sub #End Region **************** CREATE PROCEDURE usp_Outbound_Login_Details ( @Agent_ID BIGINT , @Extno VARCHAR(50), @IPAddress VARCHAR(50) = 0 ) AS BEGIN SET NOCOUNT ON DECLARE @LoginDateTime AS DATETIME SET @LoginDateTime = GETDATE() INSERT INTO Outbound_Login_Details WITH (ROWLOCK) ( Agent_ID , Login_Time , ExtNo,IPAddress ) VALUES ( @Agent_ID , @LoginDateTime , @ExtNo,@IPAddress ) SELECT Outbound_Login_ID FROM Outbound_Login_Details (NOLOCK) WHERE Agent_ID = @Agent_ID AND Login_Time = @LoginDateTime AND Extno = @ExtNo END GO this vb.net code gives me ex.Message = "Procedure or function usp_Outbound_Login_Details has too many arguments specified." Please what wrong in vb.net code.....

          V Offline
          V Offline
          Vimalsoft Pty Ltd
          wrote on last edited by
          #4

          hi man Number one try to change you Procedure to be like this, you have Complicated things in your Procedure, remember the order of declaration is important in your Procedure Create Procedure usp_OutBound_Login_Details ( @Agent_ID BIGINT , @Extno VARCHAR(50), @LoginDateTime AS DATETIME, @IPAddress VARCHAR(50) = 0 ) as Insert into OutBound_Login_Details With(RowLock) (Agent_ID , ExtNo,Login_Time,IPAddress) Values( @Agent_ID,@Extno,Getdate(),@IPAddress) SELECT Outbound_Login_ID FROM Outbound_Login_Details (NOLOCK) WHERE Agent_ID = @Agent_ID And Login_Time = Getdate() AND Extno = @ExtNo number two your Procedure Expect Parameters and you did not supply them from your Sub, i see that you are supplying values but where does those values come from? do they fly into the Sub from nowhere ? number three you have Declared a variable "@IPAddress" and initialized it to 0, and now your procedure that you are calling from your vb code need that parameter and you did not supply it. Why dont you make an IP address a default value of "0" and dont include it in your Procedure, see how i got rid of the @LoginDateTime variable, you are wasting resouce's. And in your Procedure does not tell us that you want to receive an Output from this Procedure, we only see your intensions in your vb code.You have done a lot of mistakes both in vb and in SQL. i suggest you Google and try step by step to spent time on your Procedure and after that you will know that you want to receive an output from a Procedure, remember to put output keyword when you declare a variable to will carry an output for you.In your vb.net code be in mind that you are supposed supply an input make sure that you show us how you get those inputs after that you must come back and show us what you did. Dont worry i learnt from Dave and Colin that is why am like this hope it helps

          Vuyiswa Maseko, Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding VB.NET/SQL7/2000/2005 http://vuyiswamb.007ihost.com http://Ecadre.007ihost.com vuyiswam@tshwane.gov.za

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups