Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reader returning null values

Status
Not open for further replies.

WayneGretzky

Programmer
Jan 12, 2004
28
US
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top