Good advice. Pretty sure you don't have to alias the
same name as the column being tested. Of course, if
you are already referencing the field elsewhere in
code, you might want to use the same name.



--- [EMAIL PROTECTED] wrote:

> If using SQL Server, you can also address this
> problem
> using either the ISNULL() or COALESCE() functions in
> the SELECT
> statement.
> 
> SELECT ISNULL(<<column>>,'') as <<column>> will
> return an empty
> string if the <<column>> is null. Remember to alias
> the ISNULL()
> function as the same name as the column being
> tested.
> 
> SELECT COALESCE(<<column>>,'') as <<column>> will
> return an empty
> string if the <<column>> is null. Likewise, remember
> to alias the
> COALESCE() function the same name as the column
> being tested.
> 
> Dallas Martin
> 
> 
> 
> Quoting Dean Fiala <[EMAIL PROTECTED]>:
> 
> > The value in this field
> > 
> > dtAllEmployees.Rows(rowcounter).Item("Employee") 
> > 
> > contains a DBNull.Value 
> > 
> > which means the value in the row for the column
> Employee is Null and cannot
> > 
> > be cast to a string
> > 
> > I find it helpful to create a shared function to
> deal with this...
> > 
> > Public Shared Function NullToEmptyString(ByVal o
> As Object) As String
> > If o Is DBNull.Value Then
> > Return ""
> > Else
> > Return o
> > End If
> > End Function
> > 
> > 
> > On 9/2/05, Ali Husain <[EMAIL PROTECTED]>
> wrote:
> > > 
> > > Sorry.... I submitted it by mistake....
> > > 
> > > 
> > > 
> > > 
> > > 
> > > Hi guys... need an extra set of eyes here:
> > > 
> > > 
> > > 
> > > CAST FROM TYPE DBNULL TO STRING ERROR
> > > 
> > > 
> > > 
> > > The dt is filled :
> > > 
> > > 
> > > 
> > > strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" &
> _
> > > 
> > > "Data Source=" &
> > >
> Server.MapPath("../database/DermaCareCalls.mdb;")
> > > 
> > > myConn = New OleDb.OleDbConnection(strConn)
> > > 
> > > myConn.Open()
> > > 
> > > 
> > > 
> > > mySql = "SELECT loginname from login where
> clinic = " & "'"
> > > & Request("clinic") & "'"
> > > 
> > > myComm = New OleDb.OleDbCommand(mySql, myConn)
> > > 
> > > myadapter = New OleDb.OleDbDataAdapter(mySql,
> myConn)
> > > 
> > > myadapter.Fill(dtAllEmployees)
> > > 
> > > 
> > > 
> > > 
> > > 
> > > I even tested to make sure the dataset is
> filled: Dim testrows As
> > > Integer = dtAllEmployees.Rows.Count
> > > 
> > > And it is.
> > > 
> > > 
> > > 
> > > 
> > > 
> > > For Each row In dtAllEmployees.Rows
> > > 
> > > 
> > > 
> > > Dim rowcounter As Integer
> > > 
> > > Dim colcounter As Integer
> > > 
> > > For Each nestedrow In dtDates.Rows
> > > 
> > > Dim calls As Integer
> > > 
> > > Dim sales As Integer
> > > 
> > > 
> > > 
> > > Dim employee As String =
> > > dtAllEmployees.Rows(rowcounter).Item("Employee")
> BREAKS HERE
> > > <<--------
> > > 
> > > 
> > > 
> > > 
> > > 
> > > Dim currentDate As Date =
> > > dtDates.Rows(rowcounter).Item(0)
> > > 
> > > dtUnformattedCallStats.Select("Employee =" &
> > > employee & " and calldate = " & currentDate)
> > > 
> > > dtUnformattedSalesStats.Select("Employee =" &
> > > employee & " and calldate = " & currentDate)
> > > 
> > > 
> > > 
> > > If Not
> > >
>
IsDBNull(dtUnformattedCallStats.Rows.Item(rowcounter).Item("callcount"))
> > > Then
> > > 
> > > calls =
> > >
>
dtUnformattedCallStats.Rows.Item(rowcounter).Item("callcount")
> > > 
> > > Else
> > > 
> > > calls = 0
> > > 
> > > End If
> > > 
> > > 
> > > 
> > > If Not
> > >
>
IsDBNull(dtUnformattedSalesStats.Rows.Item(rowcounter).Item("callcount")
> > > ) Then
> > > 
> > > sales =
> > >
>
dtUnformattedSalesStats.Rows.Item(rowcounter).Item("callcount")
> > > 
> > > Else
> > > 
> > > sales = 0
> > > 
> > > End If
> > > 
> > > 
> > > 
> > > 
> > > 
> > > ********* CODE TO WRITE TO PDF FILE
> > > 
> > > 
> > > 
> > > Blah blah blah
> > > 
> > > 
> > > 
> > > rowcounter += 1
> > > 
> > > Next
> > > 
> > > colcounter += 1
> > > 
> > > Next
> > > 
> > > 
> > > 
> > > [Non-text portions of this message have been
> removed]
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > Yahoo! Groups Links
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > 
> > 
> > -- 
> > Dean Fiala
> > Very Practical Software, Inc
> > http://www.vpsw.com
> > 
> > 
> > [Non-text portions of this message have been
> removed]
> > 
> > 
> > 
> > 
> >  
> > Yahoo! Groups Links
> > 
> > 
> > 
> >  
> > 
> > 
> 
> 
> 
> 
> ------------------------ Yahoo! Groups Sponsor
> --------------------~--> 
> Most low income households are not online. Help
> bridge the digital divide today!
>
http://us.click.yahoo.com/cd_AJB/QnQLAA/TtwFAA/saFolB/TM
>
--------------------------------------------------------------------~->
> 
> 
>  
> Yahoo! Groups Links
> 
> http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
> 
>    
> [EMAIL PROTECTED]
> 
>  
> 
> 
> 



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Most low income households are not online. Help bridge the digital divide today!
http://us.click.yahoo.com/cd_AJB/QnQLAA/TtwFAA/saFolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to