过程或函数有太多的参数 [英] Procedure or Function has too many argument

查看:81
本文介绍了过程或函数有太多的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi
问题,其中将数据插入表中。使用vwd 2012和Mssql 2012.插入命令在第一个记录中正常工作。如果添加另一条记录,则显示过程或函数有太多参数我尝试了很多方法,我无法解决。请帮助我。下面是我的商店程序,类文件和aspx.vb文件。



商店程序

hi problem in where insert data into table. Using vwd 2012 and Mssql 2012. Insert command is working fine in first record. If add another record, it shows "Procedure or Function has too many argument" I have tried many way, I could not solve. Pls help me. Below is my Store Procedure, Class file and aspx.vb files.

Store Procedure

GO
/****** Object:  StoredProcedure [dbo].[usp_CommonInfo_Insert]   ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER Procedure [dbo].[usp_CommonInfo_Insert]
	@Code nvarchar(10) = NULL,
	@Name nvarchar(100) = NULL,
	@Type nvarchar(10) = NULL,
	@BAddress nvarchar(150) = NULL,
	@SAddress nvarchar(150) = NULL,
	@Tel1 nvarchar(20) = NULL,
	@Tel2 nvarchar(20) = NULL,
	@Fax1 nvarchar(20) = NULL,
	@Fax2 nvarchar(20) = NULL,
	@Email nvarchar(30) = NULL,
	@ContactName nvarchar(30) = NULL,
	@ContactTel nvarchar(20) = NULL,
	@BusinessNature nvarchar(50) = NULL,
	@CrLt numeric(18,2) = NULL,
	@Terms numeric(18,0) = NULL,
	@BillType nvarchar(10) = NULL,
	@OpDate datetime = NULL,
	@OpBal numeric(18,2) = NULL,
	@CreatedOn datetime = NULL,
	@CreatedBy nvarchar(10) = NULL,
	@LastUpdate datetime = NULL,
	@LastUpdateBy nvarchar(10) = NULL,
	@Terminal nvarchar(50) = NULL,
	@UptodateSales numeric(18,2) = NULL,
	@UpToDatePaid numeric(18,2) = NULL,
	@PrePaid numeric(18,2) = NULL,
	@Balance numeric(18,2) = NULL
As
Begin
	Insert Into CommonInfo
		([Code],[Name],[Type],[BAddress],[SAddress],[Tel1],[Tel2],[Fax1],[Fax2],[Email],[ContactName],[ContactTel],[BusinessNature],[CrLt],[Terms],[BillType],[OpDate],[OpBal],[CreatedOn],[CreatedBy],[LastUpdate],[LastUpdateBy],[Terminal],[UptodateSales],[UpToDatePaid],[PrePaid],[Balance])
	Values
		(@Code,@Name,@Type,@BAddress,@SAddress,@Tel1,@Tel2,@Fax1,@Fax2,@Email,@ContactName,@ContactTel,@BusinessNature,@CrLt,@Terms,@BillType,@OpDate,@OpBal,@CreatedOn,@CreatedBy,@LastUpdate,@LastUpdateBy,@Terminal,@UptodateSales,@UpToDatePaid,@PrePaid,@Balance)

	Declare @ReferenceID int
	Select @ReferenceID = @@IDENTITY

	Return @ReferenceID

End





dbl_clients.vb





dbl_clients.vb

Public Function SaveMode(incode As String, inname As String, intype As String, inbaddress As String, insaddress As String, _
                            intel1 As String, intel2 As String, infax1 As String, infax2 As String, inemail As String, incontactname As String, incontacttel As String, _
                            inbusiness As String, incrlt As Decimal, interms As Integer, inbilltype As String, inopdate As Date, inopbal As Decimal, _
                            increatedOn As Date, increatedby As String, inlastupdate As String, inlastupdateby As String, interminal As String, _
                            inuptodatesales As Decimal, inuptodatepaid As Decimal, inprepaid As Decimal, inbalance As Decimal) As String
       'SaveMode = True
       SaveMode = String.Empty

       Try
           cmd.Connection = conn
           cmd.CommandType = CommandType.StoredProcedure
           cmd.CommandText = "usp_CommonInfo_Insert"

           cmd.Parameters.AddWithValue("@Code", incode)
           cmd.Parameters.AddWithValue("@Name", UCase(inname))
           cmd.Parameters.AddWithValue("@Type", intype)
           cmd.Parameters.AddWithValue("@BAddress", inbaddress)
           cmd.Parameters.AddWithValue("@SAddress", insaddress)
           cmd.Parameters.AddWithValue("@Tel1", intel1)
           cmd.Parameters.AddWithValue("@Tel2", intel2)
           cmd.Parameters.AddWithValue("@Fax1", infax1)
           cmd.Parameters.AddWithValue("@Fax2", infax2)
           cmd.Parameters.AddWithValue("@Email", inemail)
           cmd.Parameters.AddWithValue("@ContactName", incontactname)
           cmd.Parameters.AddWithValue("@ContactTel", incontacttel)
           cmd.Parameters.AddWithValue("@BusinessNature", inbusiness)
           cmd.Parameters.AddWithValue("@CrLt", incrlt)
           cmd.Parameters.AddWithValue("@Terms", interms)
           cmd.Parameters.AddWithValue("@BillType", inbilltype)
           cmd.Parameters.AddWithValue("@OpDate", inopdate)
           cmd.Parameters.AddWithValue("@OpBal", inopbal)
           cmd.Parameters.AddWithValue("@CreatedOn", Date.Now)
           cmd.Parameters.AddWithValue("@CreatedBy", increatedby)
           cmd.Parameters.AddWithValue("@LastUpdate", Date.Now)
           cmd.Parameters.AddWithValue("@LastUpdateBy", increatedby)
           cmd.Parameters.AddWithValue("@Terminal", interminal)
           cmd.Parameters.AddWithValue("@UptodateSales", 0)
           cmd.Parameters.AddWithValue("@UpToDatePaid", 0)
           cmd.Parameters.AddWithValue("@PrePaid", 0)
           cmd.Parameters.AddWithValue("@Balance", 0)

           Dim da As New SqlDataAdapter(cmd)
           Dim dt As New DataTable
           da.Fill(dt)
           cmd.Dispose()
           conn.Close()
       Catch ex As Exception
           SaveMode = ex.Message.ToString
       Finally
           cmd.Dispose()
           conn.Close()

       End Try
       Return SaveMode
   End Function





client_ADD.aspx.vb





client_ADD.aspx.vb

Private Sub SaveMode()
        Dim errmsg As String
        errmsg = dblClient.SaveMode(txtCode.Text, Me.txtName.Text, cboType.SelectedValue, txtBAddres.Text, txtSAddress.Text, _
                                    txtTel1.Text, txtTel2.Text, txtFax1.Text, txtFax2.Text, txtEmail.Text, txtContactName.Text, _
                                    "ContactTel", txtBusiness.Text, txtCrLt.Text, txtTerms.Text, cboBillType.SelectedValue, txtOPDate.Text, _
                                    txtOPBal.Text, Date.Now, Request.Cookies("userid").Value, Date.Now, Request.Cookies("userid").Value, _
                                    "Terminal", 0, 0, 0, 0)

        If errmsg <> String.Empty Then
            ScriptManager.RegisterStartupScript(Me, Me.[GetType](), "Message", "alert('Error occured : " & errmsg & "');", True)
        Else
            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "alert", "alert('Record Saved !');", True)
            Response.Redirect("client_View.aspx")
        End If
end sub





请帮我



Pls Help Me

推荐答案

在你的函数内再次启动cmd。

initailize cmd again inside the your function.
  Dim cmd As New SqlCommand()

will solve your problem.


debug并查看正在发送的no.of值可能是空值,所以它显示错误
debug and see the no.of values are being sending it might be a null values, so it showing up the error


这篇关于过程或函数有太多的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆