0

エラーが発生しました-「データ型「int」をに変換中にエラーが発生しましたnvarchar

VB6 コードは次のとおりです。

Private Sub Form_Load()
On Error GoTo ErrDoor
Dim lvRS_Status As New ADODB.Recordset
    If gFn_OpenCnn = True Then
    If lvRS_Status.State = adStateOpen Then lvRS_Status.Close
      lvRS_Status.Open "Select Sts_StatusID,Sts_StatusDesc from Status_mst", gvCnn_CBSBSDB, adOpenDynamic, adLockOptimistic, adCmdText
      If lvRS_Status.RecordCount <> 0 Then
        Dcbo_Status.ListField = "Sts_StatusDesc"
        Dcbo_Status.BoundColumn = "Sts_StatusID"
        Set Dcbo_Status.RowSource = lvRS_Status
      End If

    End If
On Error GoTo 0
Exit Sub
ErrDoor:
    MsgBox Error$, vbExclamation
End Sub

Private Sub Cmd_OK_Click()
On Error GoTo ErrDoor
Dim lvStr_Month As String
Dim lvStr_Year As String
Dim lvStr_SelectionFormula As String
Dim lvStr_StationName As String
Dim lvDbl_CurrentSessionID As Double
lvStr_SelectionFormula = ""
 lvDbl_CurrentSessionID = Int((2000 * Rnd) + 1000)

    gvCnn_CBSBSDB.BeginTrans
    gvCnn_CBSBSDB.Execute "Exec DBPrc_SundryDebrorAgewiseDetails " & lvDbl_CurrentSessionID & ", '" & Dcbo_Status.BoundText & "', " & Cbo_SelectMonth.ListIndex + 1 & ", " & Txt_SelectYear.Text & ""
    gvCnn_CBSBSDB.CommitTrans


    Crpt_SundryDebtor.Reset
    Crpt_SundryDebtor.WindowState = crptMaximized


    Crpt_SundryDebtor.ReportFileName = App.Path & "\sundrydebtor_agewise.rpt"
    Crpt_SundryDebtor.DiscardSavedData = True
   If Trim(Cbo_SelectMonth.Text) <> "" Then
       lvStr_Month = "{SundryDebtors_AgeWise.lvStr_Month} = " & Cbo_SelectMonth.ItemData(Cbo_SelectMonth.ListIndex)
       lvStr_SelectionFormula = lvStr_Month
   Else
       MsgBox "Select the month ", vbInformation, "Sundry Debtor Age wise"
       Exit Sub
   End If


   If Trim(Txt_SelectYear.Text) <> "" Then

           lvStr_Month = lvStr_SelectionFormula + " And {SundryDebtors_AgeWise.Sde_Year}  =" & Txt_SelectYear.Text
           lvStr_SelectionFormula = lvStr_Month

    End If


    If Trim(Dcbo_Status.Text) <> "" Then
        If lvStr_SelectionFormula <> "" Then
           lvStr_Month = lvStr_SelectionFormula + " And {Status_Mst.Sts_StatusID} =" & val(Dcbo_Status.BoundText) & ""
           lvStr_SelectionFormula = lvStr_Month
        End If
    End If


    Crpt_SundryDebtor.SelectionFormula = "{Reporter.Session_ID} = " & lvDbl_CurrentSessionID & ""
        Crpt_SundryDebtor.Connect = gvCnn_CBSBSDB
        Crpt_SundryDebtor.DiscardSavedData = True
        Crpt_SundryDebtor.WindowShowRefreshBtn = True
        Crpt_SundryDebtor.WindowShowPrintSetupBtn = True
        Crpt_SundryDebtor.Destination = crptToWindow
        Crpt_SundryDebtor.Action = 1



On Error GoTo 0
Exit Sub
Resume
ErrDoor:
    MsgBox Error$, vbExclamation

End Sub

ストアド プロシージャは次のとおりです。

CREATE PROCEDURE DBPrc_SundryDebrorAgewiseDetails(
  @SessionId as int,
  @StatusId as int,
  @Month as nvarchar,
  @Year as nvarchar)
as 
begin
if @StatusId=''
begin
    SELECT
      @SessionId,
      Sts_StatusDesc, Agt_AgentName,Sde_OutstandingAsOnDate,
      Sde_AmountLessThanSixMonths,
      Sde_AmountBetweenSixMonthstoOneYear,Sde_AmountBetweenOneToTwoYear,
      Sde_AmountBetweenTwoToThreeYears,Sde_AmountMoreThanThreeYears,
      Sde_TotalAdChanrges,Sde_TotalProgressiveInterest,Sde_TotalOutstandingAsOnDate,
      Sde_Remark, Sde_SundryDebtorCode
    FROM SundryDebtors_AgeWise left join Status_Mst
           on sts_StatusId=Sde_StatusId
         left join Agent_Mst
           on Agt_AgentId=Sde_AgentId
    WHERE SundryDebtors_AgeWise.Sde_Month=@Month 
      and SundryDebtors_AgeWise.Sde_Year=@Year 
    GROUP BY Sts_StatusDesc, Agt_AgentName,Sde_OutstandingAsOnDate,Sde_AmountLessThanSixMonths,Sde_AmountBetweenSixMonthstoOneYear,Sde_AmountBetweenOneToTwoYear,Sde_AmountBetweenTwoToThreeYears,Sde_AmountMoreThanThreeYears,Sde_TotalAdChanrges,Sde_TotalProgressiveInterest,Sde_TotalOutstandingAsOnDate,Sde_Remark,Sde_SundryDebtorCode

End

If @StatusId<>''
Begin

    SELECT
      @SessionId,
      Sts_StatusDesc,Agt_AgentName,Sde_OutstandingAsOnDate,
      Sde_AmountLessThanSixMonths,Sde_AmountBetweenSixMonthstoOneYear,
      Sde_AmountBetweenOneToTwoYear,Sde_AmountBetweenTwoToThreeYears,
      Sde_AmountMoreThanThreeYears,Sde_TotalAdChanrges,Sde_TotalProgressiveInterest,
      Sde_TotalOutstandingAsOnDate,Sde_Remark,Sde_SundryDebtorCode
    FROM SundryDebtors_AgeWise left join Status_Mst
           on sts_StatusId=Sde_StatusId
         left join Agent_Mst
         on Agt_AgentId=Sde_AgentId
    WHERE SundryDebtors_AgeWise.Sde_Month=@Month 
      and SundryDebtors_AgeWise.Sde_Year=@Year 
      and Sts_StatusId=@StatusId
    GROUP BY Sts_StatusDesc, Agt_AgentName,Sde_OutstandingAsOnDate,Sde_AmountLessThanSixMonths,Sde_AmountBetweenSixMonthstoOneYear,Sde_AmountBetweenOneToTwoYear,Sde_AmountBetweenTwoToThreeYears,Sde_AmountMoreThanThreeYears,Sde_TotalAdChanrges,Sde_TotalProgressiveInterest,Sde_TotalOutstandingAsOnDate,Sde_Remark,Sde_SundryDebtorCode
End

End
GO
4

1 に答える 1

1

SP パラメータは int です:
@StatusId as int,

...まだ空の文字列 '' に対してテストしています:
if @StatusId=''

于 2013-03-26T11:12:49.287 に答える