Subject: Another "No value given…" Problem
Posted By: madcatrobert Post Date: 12/7/2006 5:27:37 PM
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.

Go to topic 53289

Return to index page 99
Return to index page 98
Return to index page 97
Return to index page 96
Return to index page 95
Return to index page 94
Return to index page 93
Return to index page 92
Return to index page 91
Return to index page 90