Får upp detta felmeddelande: Klassisk felsökning, kör koden normalt i debug-läge och se var det smäller någonstans.Fel i kod?? Bugg??
Microsoft OLE DB Provider for ODBC Drivers (0x80040E21)
En OLE DB-åtgärd i flera steg genererade fel. Kontrollera alla OLE DB-statusvärden som finns tillgängliga. Inget arbete utfördes.
koden ser ut såhär:
<code>
Function SerieNummerEtikett(purchnum, linenum, prodnum)
Dim DBConn
Dim objCmd, objCmd2
Dim oRs, oRs2
Dim rs, rs2
Dim sSql, sSql2
Dim StoredProc, StoredProc2
StockItemLength = 1
If Session.Contents("Function").OpenDBConn(DBConn) Then
'Declare stored Procedure
StoredProc = "Sp_SeriesNo"
If Session.Contents("Function").OpenCmd(DBConn, objCmd, StoredProc) Then
objCmd.Parameters.Append objCmd.CreateParameter("@PurchNo", 200, 1, 10, purchnum)
objCmd.Parameters.Append objCmd.CreateParameter("@LineNo", 14, 1, 13, linenum)
objCmd.Parameters.Append objCmd.CreateParameter("@CreditorAccount", 200, 1, 10, Session.Contents("AccountNumber"))
Set oRs = objCmd.Execute
'Declare stored proc
StoredProc2 ="Sp_MrpTable"
If Session.Contents("Function").OpenCmd(DBConn, objCmd2, StoredProc2) Then
objCmd2.Parameters.Append objCmd.CreateParameter("@ProdNo", 200, 1, 20, prodnum)
Set oRs2 = objCmd2.Execute
If oRs2("REFPRODNUMBER") > 0 Then
sSql = "SELECT dbo.STOCKTABLE.BUYQUANTY FROM dbo.STOCKTABLE, dbo.MRPTABLE WHERE dbo.MRPTABLE.PRODNUMBER = '" & oRs2("REFPRODNUMBER") & "' AND dbo.MRPTABLE.ITEMNUMBER = dbo.STOCKTABLE.ITEMNUMBER"
If Session.Contents("Function").OpenRS(DBConn, rs, sSql) Then
BuyQuantity(StockItemLength) = rs("BUYQUANTY")
End If
Else
sSql = "SELECT dbo.STOCKTABLE.BUYQUANTY FROM dbo.STOCKTABLE, dbo.MRPTABLE WHERE dbo.MRPTABLE.PRODNUMBER = '" & prodnum & "' AND dbo.MRPTABLE.ITEMNUMBER = dbo.STOCKTABLE.ITEMNUMBER"
If Session.Contents("Function").OpenRS(DBConn, rs2, sSql2) Then
BuyQuantity(StockItemLength) = rs2("BUYQUANTY")
End If
End If
End If
Do While Not oRs.EOF
SeriesNumber(StockItemLength) = oRs("BATCHSERIESNO")
ItemNumber(StockItemLength) = oRs("ITEMNUMBER")
QtyOrdered(StockItemLength) = oRs("QTYORDERED")
LineNumber(StockItemLength) = oRs("LINENO_")
CreditorAccount(StockItemLength) = oRs("CREDITORACCOUNT")
Delivered(StockItemLength) = oRs("DELIVERED")
StockItemLength = StockItemLength + 1
oRs.MoveNext
Loop
StockItemLength = StockItemLength - 1
SerieNummerEtikett = StockItemLength
Call Session.Contents("Function").CloseCmd(oRs)
Else
'Declare stored procedure
StoredProc = "Sp_NoSeriesNo"
If Session.Contents("Function").OpenCmd(DBConn, objCmd, StoredProc) Then
objCmd.Parameters.Append objCmd.CreateParameter("@PurchNo", 200, 1, 10, purchnum)
objCmd.Parameters.Append objCmd.CreateParameter("@LineNo", 14, 1, 13, linenum)
objCmd.Parameters.Append objCmd.CreateParameter("@CreditorAccount", 200, 1, 10, Session.Contents("AccountNumber"))
Set oRs = objCmd.Execute
SeriesNumber(StockItemLength) = oRs("PURCHASENUMBER")
ItemNumber(StockItemLength) = oRs("ITEMNUMBER")
QtyOrdered(StockItemLength) = oRs("QTYORDERED")
LineNumber(StockItemLength) = oRs("LINENO_")
CreditorAccount(StockItemLength) = oRs("CREDITORACCOUNT")
Delivered(StockItemLength) = oRs("DELIVERED")
End If
'declare stored procedure
StoredProc2 = "Sp_MrpTable"
If Session.Contents("Function").OpenCmd(DBConn, objCmd2, StoredProc2) Then
objCmd2.Parameters.Append objCmd2.CreateParameter("@ProdNo", 200, 1, 20, prodnum)
Set oRs2 = objCmd2.Execute
If oRs2("REFPRODNUMBER") > 0 Then
sSql = "SELECT dbo.STOCKTABLE.BUYQUANTY FROM dbo.STOCKTABLE, dbo.MRPTABLE WHERE dbo.MRPTABLE.PRODNUMBER = '" & oRs2("REFPRODNUMBER") & "' AND dbo.MRPTABLE.ITEMNUMBER = dbo.STOCKTABLE.ITEMNUMBER"
If Session.Contents("Function").OpenRS(DBConn, rs, sSql) Then
BuyQuantity(StockItemLength) = rs("BUYQUANTY")
End If
Else
sSql2 = "SELECT dbo.STOCKTABLE.BUYQUANTY FROM dbo.STOCKTABLE, dbo.MRPTABLE WHERE dbo.MRPTABLE.PRODNUMBER = '" & prodnum & "' AND dbo.MRPTABLE.ITEMNUMBER = dbo.STOCKTABLE.ITEMNUMBER"
If Session.Contents("Function").OpenRS(DBConn, rs2, sSql2) Then
BuyQuantity(StockItemLength) = rs2("BUYQUANTY")
End If
End If
End If
SerieNummerEtikett = StockItemLength
End If
Call Session.Contents("Function").CloseDBConn(DBConn)
Else
SerieNummerEtikett = -1
End If
If BuyQuantity(1) = 0 Then
BuyQuanity(1) = 1
ElseIf BuyQuantity(1) = "" Then
BuyQuantity(1)
End If
End Function
</code>
Är ingen sql expert så jag har kommit till en punkt där jag inte riktigt förstår vad problemet är.. har läst omkring och har hittat en del.. men det hjälper mig inte direkt... någon??Sv: Fel i kod?? Bugg??
Hälsningar
/Pelle