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 Sponsor --------------------~-->
Fair play? Video games influencing politics. Click and talk back!
http://us.click.yahoo.com/T8sf5C/tzNLAA/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/