SQL 2003错误 - System.ArgumentException:列“数量”不属于表1

时间:2016-01-27 16:50:53

标签: sql-server

我正在使用Visual Studio构建一个连接到我的MSSQL 2003 Server的软件。我试图从表中提取数据,以便在存储过程中使用它,并收到以下错误。

System.ArgumentException:列'Quantity'不属于表TMS_Campaign。

我已经仔细检查了列名拼写正确并且大小写正确。我还试图做一个IISRESET.exe,只是根据其他帖子的推荐重新启动机器。

Sub SendMail()
    Dim SQL As String
    Dim oDS As New Data.DataSet
    Dim oDT As New Data.DataTable
    Dim ServerID As Integer = GetServerID()


    SQL = "exec sp_Check " & ServerID
    oDT = GetRS(SQL)

    If oDT.Rows.Count = 0 Then
        'if there is NO item set status = Ready and EXIT
        SQL = "UPDATE TMS_Server" & vbCrLf &
                 "SET StatusID = 3," & vbCrLf &
                 "StatusDateTime = GetDate()" & vbCrLf &
                 "WHERE SID = " & ServerID
        AddLineToLog("No Schedule - " & Now)
        Application.DoEvents()
        Wait(5)
    Else
        'set IDs
        G.MID = oDT.Rows(0)("MID")
        G.CID = oDT.Rows(0)("CID")
        G.LID = oDT.Rows(0)("LID")
        G.SFID = oDT.Rows(0)("SFID")
        G.LastID = oDT.Rows(0)("LastID")
        G.BatchSize = oDT.Rows(0)("BatchSize")
        G.Quantity = oDT.Rows(0)("Quantity")

        'GET LIST

        ExecuteSQL("sp_GetOrderID_V4 " & G.LID & "," & G.MID & "," & G.Quantity)

编辑 - 评论代码:

CREATE proc sp_CheckForCampaign 
@ServerID int as 
 SELECT TOP 1 MID, L.LID, L.AKID, L.AKLevel, C.CID, C.Warm, SFID, LaunchDateTime, LastID, BatchSize, BatchInterval 
FROM TMS_Mailings M 
INNER JOIN TMS_Campaign C ON M.CID = C.CID 
INNER JOIN TMS_Server S ON M.SID = S.SID 
INNER JOIN TMS_List L ON M.LID = L.LID 
WHERE LaunchDateTime < GetDate() 
AND M.SID = @ServerID 
AND M.StatusID IN (1,2) -- Scheduled, Mailing 
ORDER BY LaunchDateTime 
GO

0 个答案:

没有答案