日期:2014-05-18  浏览次数:20561 次

各位老大帮帮忙 救救急
用vb调用下面的存储过程时为什么提示 从数据类型 nvarchar 转换为numeric 时出错 ??? 谢谢

USE [SOE006]
GO
/****** 对象: StoredProcedure [dbo].[AddzjSubsidiary] 脚本日期: 05/13/2010 09:41:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
ALTER Procedure [dbo].[AddzjSubsidiary]  
@ID int,
@Vouchtype nvarchar(50),
@CCode nvarchar(50),
@CustomerCode nvarchar(50),
@DepartCode nvarchar(50),
@EmployeeCode nvarchar(50),
@DDate smalldatetime,
@DispatcharCode nvarchar(50),
@Number decimal(18, 6),
@HaierCode nvarchar(50),
@Marker nvarchar(50),
@Checker nvarchar(50),
@Accounter nvarchar(50),
@AccDate smalldatetime,
@jhdate smalldatetime

AS  
  insert into zjSubsidiary  
select @id,@vouchtype,@ccode,@CustomerCode, @DepartCode, @EmployeeCode, @DDate, @DispatcharCode, @HaierCode, b.providercode,@jhdate,a.productcode,cast(a.number*@number*(b.fquota/100) as decimal(18, 6)),
a.price,cast(a.money*@number*(b.fquota/100) as decimal(18, 6)) ,a.fvagquantity,cast(a.sumfvag*@number*(b.fquota/100) as decimal(18, 6)),@Marker, @Checker, @Accounter, @AccDate from ProductStructures a inner join venandinv b on a.productcode=b.productcode
where a.haiercode=@haiercode

vb的调用如下: 帮忙看看有否问题 谢谢

Dim cmdTEMP As New ADODB.Command
  Dim parTEMP As New ADODB.Parameter
  Dim RsTemp As New ADODB.Recordset
  Dim i As Integer
  Dim QM As Currency
   
  For i = 1 To VFG1.Rows - 2
  With cmdTEMP
  .ActiveConnection = P_connection
  .CommandType = adCmdStoredProc
  .CommandText = "addCTSubsidiary"
   
  '参数1 主表id
  Set parTEMP = .CreateParameter("ID", adBigInt, adParamInput, , RSMain!Id)
  .Parameters.Append parTEMP
  '参数2 单据类型
  Set parTEMP = .CreateParameter("Vouchtype", adVarWChar, adParamInput, 50, "01")
  .Parameters.Append parTEMP
  '参数3 单据号
  Set parTEMP = .CreateParameter("CCode", adVarWChar, adParamInput, 50, TxtFaHuoDanNumber.Text)
  .Parameters.Append parTEMP
  '参数4 CustomerCode
  Set parTEMP = .CreateParameter("CustomerCode", adVarWChar, adParamInput, 50, TxtCustomer.Tag)
  .Parameters.Append parTEMP
  '参数5 DepartCode
  Set parTEMP = .CreateParameter("DepartCode", adVarWChar, adParamInput, 50, TxtBM.Tag)
  .Parameters.Append parTEMP
  '参数6 业务员
  Set parTEMP = .CreateParameter("EmployeeCode", adVarWChar, adParamInput, 50, TxtYWY.Tag)
  .Parameters.Append parTEMP
  '参数7 单据日期
  Set parTEMP = .CreateParameter("DDate", adDate, adParamInput, , DTPChKRQ.Value)
  .Parameters.Append parTEMP
  '参数8 DispatcharCode
   
  Set parTEMP = .CreateParameter("DispatcharCode", adVarWChar, adParamInput, 50, TxtChKLB.Tag)
  .Parameters.Append parTEMP
  '参数9 number
  Set parTEMP = .CreateParameter("Number", adNumeric, adParamInput, , Val(VFG1.TextMatrix(i, Con_Col_Num)))
  parTEMP.Precision = 18
  parTEMP.NumericScale = 6
  .Parameters.Append parTEMP
   
  '参数10 haiercode
  Set parTEMP = .CreateParameter("haiercode", adVarWChar, adParamInput, 50, VFG1.TextMatrix(i, Con_Col_Code))
  .Parameters.Append parTEMP
  '11 Marker
  Set parTEMP = .CreateParameter("Marker", adVarWChar, adParamInput, 50, TxtZhDR.Text)
  .Parameters.Append parTEMP
  '12
  Set parTEMP = .CreateParameter("Checker", adVarWChar, adPar