I make a query in coding. But I got conversion error. Please check my fault.
My query is below
Dim strSelect As String = ""
strSelect = "SELECT " & _
"Description As [Desc], " & _
"iif(CurCons = 0, " - ", CurCons) As [CCQty] " & _
"FROM tblCur"
Exception error is like
Conversion from string “iif(CurCons =
0, ” to type ‘Double’ is not valid
Acturally, in my report, i wanna show if it’s zero then ‘-‘. If i set it in this string. I got another error like below
The provider could not determine the
Decimal value. For example, the row
was just created, the default for the
Decimal column was not available, and
the consumer had not yet set a new
Decimal value.
From da.Fill
Dim cmd As New OleDbCommand(strDynamic, m_DBConn)
Dim da As New OleDbDataAdapter(cmd)
da.Fill(ds, "tblCur")
How to solve this?
You are still in the SQL Query when you are doing the IIF statement, so you do not want to use the “ characters for strings, instead you will use ‘.
Your report would need the field where the value is outputted to be set to the Text type, otherwise you will see an error.