F
Fabio Papa
Hi,
I am fairly new to programming and and even newer to dotnet. I appoligise
in advance if this is a dumb questions, and I would appreciate if you could
answer it anyways.
I am writing a windows service wich sends emails to customers at a specific
time. My app retrieves cities and the city's associated time from a
database, waits until the specified time for each city and sends out the
appropriate emails. Below is some code that is generating a
NullReferenceException which I haven't been able to debug. Please help!
Friend Class RgsDbConnection
Private rgsConn As SqlConnection
Private Shared goTimes() As Date
Private Shared locales() As String
Private Shared _numLocales As Integer
....
Private Sub GetLocalesAndTimes()
Dim cmd As SqlDataAdapter
Dim rsData As New DataSet
Dim i As Integer
'Get a list of all locales and their email/fax sending time
cmd = New SqlDataAdapter("SELECT zonename, EmailFaxTime " _
& "FROM dbo.tblzone", me.rgsConn)
cmd.Fill(rsData, "LocalesAndTimes")
'Get number of locales
me._numLocales = rsData.Tables("LocalesAndTimes").Rows.Count
For i = 0 To me._numLocales - 1
'fill array with locales
Dim log as EventLog = New EventLog()
Try
'This next line is the one that causes the error
Me.locales(i) =
rsData.Tables("LocalesAndTimes").Rows(i).Item("zonename")
Catch e As Exception
log.WriteEntry("RGS Email & Fax Sender", _
rsData.Tables("LocalesAndTimes").Rows(i).Item("zonename").ToString())
log.WriteEntry("RGS Email & Fax Sender", e.ToString)
End Try
'fill array with sending times
' me.goTimes(i) = _
' rsData.Tables("LocalesAndTimes").Rows(i).Item("EmailFaxTime")
Next i
End Sub
....
End Class
In the "For...Next" block you will notice a "Try" block inside the try block
is the single line of code that is causing the problem. Thanks in advance
for your help.
fabio
I am fairly new to programming and and even newer to dotnet. I appoligise
in advance if this is a dumb questions, and I would appreciate if you could
answer it anyways.
I am writing a windows service wich sends emails to customers at a specific
time. My app retrieves cities and the city's associated time from a
database, waits until the specified time for each city and sends out the
appropriate emails. Below is some code that is generating a
NullReferenceException which I haven't been able to debug. Please help!
Friend Class RgsDbConnection
Private rgsConn As SqlConnection
Private Shared goTimes() As Date
Private Shared locales() As String
Private Shared _numLocales As Integer
....
Private Sub GetLocalesAndTimes()
Dim cmd As SqlDataAdapter
Dim rsData As New DataSet
Dim i As Integer
'Get a list of all locales and their email/fax sending time
cmd = New SqlDataAdapter("SELECT zonename, EmailFaxTime " _
& "FROM dbo.tblzone", me.rgsConn)
cmd.Fill(rsData, "LocalesAndTimes")
'Get number of locales
me._numLocales = rsData.Tables("LocalesAndTimes").Rows.Count
For i = 0 To me._numLocales - 1
'fill array with locales
Dim log as EventLog = New EventLog()
Try
'This next line is the one that causes the error
Me.locales(i) =
rsData.Tables("LocalesAndTimes").Rows(i).Item("zonename")
Catch e As Exception
log.WriteEntry("RGS Email & Fax Sender", _
rsData.Tables("LocalesAndTimes").Rows(i).Item("zonename").ToString())
log.WriteEntry("RGS Email & Fax Sender", e.ToString)
End Try
'fill array with sending times
' me.goTimes(i) = _
' rsData.Tables("LocalesAndTimes").Rows(i).Item("EmailFaxTime")
Next i
End Sub
....
End Class
In the "For...Next" block you will notice a "Try" block inside the try block
is the single line of code that is causing the problem. Thanks in advance
for your help.
fabio