Im trying to make a form so the client can type in their email address and have their activation email resent - similar to a password resend form

The following works, except it will include activation codes for orders that havnt been paid for.

I have a seperate Orders table which has a column Paid - orders which have been paid are marked -1

I cant figure out how to retrieve just the activation codes for the orders which have been paid

I have tried making a query in the dataset such as

SELECT CustomerEmail
FROM orders
WHERE (IsPaid = -1)
However i dont know if this is right or how to implement it into the following:

vb Code:
  1. Private Sub sendemail()
  2.         Dim CustomerEmail As String
  3.  
  4.         CustomerEmail = txtCustomerEmail.Text
  5.         'Checks if Email is in DB
  6.         Dim da As New ProjectDataSetTableAdapters.LicenseTableAdapter()
  7.         Dim dt As ProjectDataSet.LicenseDataTable = da.GetDataByCustomerEmail(CustomerEmail)
  8.         If dt.Rows.Count = 0 Then
  9.             txtCustomerEmail.Text = "Email Address Not Found"
  10.         Else
  11.             'Check if the order has been paid
  12.  
  13.             '*********************************
  14.             '*********************************
  15.  
  16.             'if so then email activaion details
  17.  
  18.             Dim daLic As New ProjectDataSetTableAdapters.LicenseTableAdapter()
  19.             Dim dtLic As ProjectDataSet.LicenseDataTable = daLic.GetDataByCustomerEmail(CustomerEmail)
  20.             If dtLic.Rows.Count > 0 Then
  21.                 Dim drLic As ProjectDataSet.LicenseRow = dtLic.Rows(0)
  22.  
  23.                 Dim msg As New MailMessage()
  24.                 msg.IsBodyHtml = False
  25.                 msg.From = New MailAddress("[email protected]", "[email protected]")
  26.                 msg.To.Add(CustomerEmail)
  27.                 msg.Subject = "MyWebsite Activation ID"
  28.  
  29.                 Dim body As New StringBuilder()
  30.                 body.AppendLine("Thank you for your purchase")
  31.                 body.AppendLine()
  32.                 body.AppendLine("Here are your activation details:")
  33.                 body.AppendLine()
  34.  
  35.                 For i As Integer = 0 To dtLic.Count - 1
  36.                     drLic = dtLic.Rows(i)
  37.                     body.AppendLine(String.Format("{0} Activation Code: {1}  |  Email: {2}", drLic.Product, drLic.ActivationCode, drLic.CustomerEmail))
  38.                     body.AppendLine(String.Format("{0} Download Link: www.MyWebsite.co.uk/{0}setup.html", drLic.Product, drLic.ActivationCode))
  39.                     body.AppendLine()
  40.                 Next
  41.                 body.AppendLine()
  42.                 body.AppendLine("Please note each license code above is for 1 PC only")
  43.                 body.AppendLine()
  44.                     body.AppendLine()
  45.                 body.AppendLine("Thank You")
  46.                 body.AppendLine()
  47.                 body.AppendLine("MyWebsite")
  48.                 body.AppendLine("www.MyWebsite.co.uk")
  49.                 body.AppendLine()
  50.                 msg.Body = body.ToString()
  51.  
  52.                 Dim smtp As New SmtpClient()
  53.                 smtp.Send(msg)
  54.             End If
  55.         End If
  56.  
  57.  
  58.     End Sub