Another "No value givenâ¦" Problem
The following code will throw an error:
Dim sConx As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=X:\xxxx.mdb;"
Dim conx As OleDbConnection = New OleDbConnection(sConx)
Dim cmdUnpdInv As OleDbCommand = New OleDbCommand(sqlUnpdInv, conx)
Dim sqlUnpdInv = "SELECT SUM([Amt]) FROM " & sTblUPdI & _
" WHERE([Paid] = False AND [InvNum] < " & Range("InvNum").Value & ");"
Try
If conx.State = ConnectionState.Closed Then
conx.Open()
End If
Dim dUnpdInvAmt As Double = CType(cmdUnpdInv.ExecuteScalar(), Double) 'Error
Catch ex As Exception
MsgBox(ex.Message)
'Msg: No value given for one or more required parameters
Finally
If conx.State = ConnectionState.Open Then
conx.Close()
End If
End Try
I am really confused as everything seems to be correct in terms of syntax etc.
Any help will be greatly appreciated.
TIA,
Madcatrobert
OOPS! I discovered the problem; it would help to use the correct column name in the SQL statement.
Please disregard this entry.
|