I am trying to send emails for records found in my dataset
I am getting Unable to cast object of type 'System.Data.DataTable' to type 'System.Data.DataRow'. and then it highlights this part of the codeVB Code:
Private Sub SendConfirmationEmail_x() Dim getZip As String = txtZip.Text Dim getRad As Integer = CInt(ddlRadius.SelectedValue) Dim myDS As DataSet = GetUE_ZipRadius(getZip, getRad) Dim intCountDs As Integer = DataList1.Items.Count Dim myDR As DataRow With myDS.Tables("ZipCodes") For Each myDR In myDS.Tables Dim strMailTo As String = myDS.Tables(1).ToString Dim strMailServer As String = "mail.*******.com" Dim strMailFrom As String = "admin@*******.com" Dim strMailSubject As String = "Test Email" Dim strMailMsg As String = "Mail Messege" Dim MailObj As New System.Net.Mail.SmtpClient MailObj.Host = strMailServer MailObj.Send( _ strMailFrom, _ strMailTo, _ strMailSubject, _ strMailMsg) Next End With myDS.Dispose() End Sub
What am I doing wrong?VB Code:
Line 154: End If Line 155: With myDS.Tables("ZipCodes") Line 156: [b]For Each myDR In myDS.Tables[/b] Line 157: Dim strMailTo As String = myDS.Tables(1).ToString Line 158: Dim strMailServer As String = "mail.uncleedsoil.com"


Reply With Quote