Hi Cathi,
It appears that you cannot & the iif( function, it gets confussed.
Thanks Again and Happy New Year!!!!!!!
Maybe it will be fixed by next year, NOT.
Sincerely,
Roland
==========================================================================
>Hi Roland,
>
>Your syntax should be okay from what I can tell. Here is a sample program that tests your syntax against the SQL Server Northwind database. This doesn't generate any errors for me. Try this code. If no errors then the problem is somewhere else in your data.
>
>
>Dim oConnStr As String = "data source=localhost;initial catalog=Northwind;user id=sa;password="
>Dim oConn As New SqlConnection()
>oConn.ConnectionString = oConnStr
>oConn.Open()
>
>' Create a Command object with select statement
>Dim strSelect As [String] = "SELECT * FROM CUSTOMERS where customerid like 'C%'"
>Dim oSelectCommand As New SqlCommand(strSelect, oConn)
>
>' Create a DataAdapter
>Dim da As New SqlDataAdapter()
>da.SelectCommand = oSelectCommand
>
>' Create a DataSet
>Dim ds As New DataSet()
>
>' Fill the DataSet with table information
>da.Fill(ds, "CUSTOMERS")
>
>Dim dr As DataRow
>For Each dr In ds.Tables("CUSTOMERS").Rows()
> MessageBox.Show(IIf(IsDBNull(dr("Region")), "Value is Null", dr("Region")))
>Next
>
>oConn.Close()
>
>
>>Hi,
>>
>>I encountered the following error message with the code below the error message.
>>
>>An unhandled exception of type 'System.InvalidCastException' occurred in microsoft.visualbasic.dll
>>Additional information: Cast from type 'DBNull' to type 'String' is not valid.
>>
>>MyEmailBody = myDataRow("AccountId") & " " & _
>>myDataRow("OrderNumber") & " " & _
>>IIf(IsDBNull(myDataRow("APN")), "", Trim(myDataRow("APN"))) & " " & _
>>IIf(IsDBNull(myDataRow("StreetNumber")), "", Trim(myDataRow("StreetNumber")))
>>
>>What is the proper code to cancanate the string?
>>
>>Any help would be greatly appreciated.
>>
>>
>>Thanks
>>Roland