WayneGretzky
Programmer
I'm trying to figure out why the Variable CustomerName is null. I need to verify if my syntax for all in this Sub is formed well:
Sub SendEmail_ElBalazo()
Dim mailObj As New MailMessage
Conn.Open()
Dim myvalue As Integer = 1
Dim cmd As SqlCommand = New SqlCommand("sp_Get_OrderDetails", Conn)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add(New SqlParameter("@CateringOrderID", Session("CateringOrderID")))
Dim reader As SqlDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
Dim CustomerName As String
Dim CustomerAddress As String
Dim CustomerCity As String
Dim CustomerState As String
Dim CustomerZip As String
Dim CustomerPhone As String
Dim CustomerEmail As String
Dim TimeOfOrder As String
Dim NumberOfPeople As String
Dim BeanOption As String
Dim TortillaOption As String
While reader.Read
CustomerName = reader("CustomerName").ToString
CustomerAddress = reader("CustomerAddress").ToString
CustomerCity = reader("CustomerCity").ToString
CustomerState = reader("CustomerState").ToString
CustomerZip = reader("CustomerZip").ToString
CustomerPhone = reader("CustomerPhone").ToString
CustomerEmail = reader("CustomerEmail").ToString
TimeOfOrder = reader("TimeOfOrder").ToString
NumberOfPeople = reader("NumberOfPeople").ToString
BeanOption = reader("BeanOption").ToString
TortillaOption = reader("TortillaOption").ToString
End While
mailObj.From = "sss@sss.net"
mailObj.To = "sss@hotmail.com"
mailObj.Subject = "New Catering Order !"
mailObj.Body = "Customer Information:<br>" & CustomerName
SmtpMail.SmtpServer = "localhost"
SmtpMail.Send(mailObj)
Conn.Close()
End Sub
Sub SendEmail_ElBalazo()
Dim mailObj As New MailMessage
Conn.Open()
Dim myvalue As Integer = 1
Dim cmd As SqlCommand = New SqlCommand("sp_Get_OrderDetails", Conn)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add(New SqlParameter("@CateringOrderID", Session("CateringOrderID")))
Dim reader As SqlDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
Dim CustomerName As String
Dim CustomerAddress As String
Dim CustomerCity As String
Dim CustomerState As String
Dim CustomerZip As String
Dim CustomerPhone As String
Dim CustomerEmail As String
Dim TimeOfOrder As String
Dim NumberOfPeople As String
Dim BeanOption As String
Dim TortillaOption As String
While reader.Read
CustomerName = reader("CustomerName").ToString
CustomerAddress = reader("CustomerAddress").ToString
CustomerCity = reader("CustomerCity").ToString
CustomerState = reader("CustomerState").ToString
CustomerZip = reader("CustomerZip").ToString
CustomerPhone = reader("CustomerPhone").ToString
CustomerEmail = reader("CustomerEmail").ToString
TimeOfOrder = reader("TimeOfOrder").ToString
NumberOfPeople = reader("NumberOfPeople").ToString
BeanOption = reader("BeanOption").ToString
TortillaOption = reader("TortillaOption").ToString
End While
mailObj.From = "sss@sss.net"
mailObj.To = "sss@hotmail.com"
mailObj.Subject = "New Catering Order !"
mailObj.Body = "Customer Information:<br>" & CustomerName
SmtpMail.SmtpServer = "localhost"
SmtpMail.Send(mailObj)
Conn.Close()
End Sub