vb.net - data reader

charlotte

Member
Joined
May 30, 2005
Messages
9
Programming Experience
Beginner
hi,a help needed!

i wanna ask some Qs regarding the datareader?


i have a select statement that select all the email add (for the badge that overdue.)

then i use datareader to read it row by row(it contain 1 column but many row! as below)

how am i going to write it coding.....


Email

abc@yahoo.com

cde@yahoo.com

hjk@hotmail.com



here is the select statement:-

Dim sEmailTo As String = "Select STFMAILID from MP_HRS_CONTACT Where STFNO in (Select STFNO From ESC_APPLICANT Where CDate(APP_VDATE_TO) < # " & DateTime.Now.ToString("dd/MM/yyyy") & "# "
Dim CmdEmailTo As New OleDbCommand(sEmailTo,
Conn)
Dim dtrReceiver As OleDbDataReader





here is for the sending email thing:-

how am i get the Receiver from the datareader?



Dim objMail As clsMail = New clsMail
Dim sSendTo As String =
' Receiver ???????? i wanna get it from the datareader
Dim sFrom As String = "
abc@yahoo.com"
Dim sCCTo As String
Dim sSubject As String
Dim sBody As String
Dim sAttachment As String

sSubject = "Request Badge has been Reject! "
sBody = "Dear colleague: " + ": "
sBody = sBody + "For more information, please contact IFIC SSE for further information. "
sBody = sBody + " Thank you and have a nice day!"

objMail.SendMail(sFrom, sSendTo, sCCTo, sSubject, sBody, sAttachment)

any ideas provided!
thanks in advance!


regards;

charlotte
 
Probably the best solution will be one that concanate all e-mail strings within textBox control and then pass to sSendTo variable ...

PHP:
 {...} 
Dim CmdEmailTo As OleDbCommand 
CmdEmailTo = New OleDbCommand(sEmailTo, Conn)
Dim dtrReceiver As OleDbDataReader
dtrReceiver = CmdEmailTo.ExecuteReader
While dtrReceiver.Read()
textBox1.Text &= dtrReceiver("yourField") & ";"   'perhaps you'll know how to remove the last semicolon from string 
End While
 
dtrReceiver.Close()
 
Dim objMail As clsMail = New clsMail 
Dim sSendTo As String = textBox1.Text
{...}



Cheers ;)
 
Hi charlotte,
As you asked for function that remove last semicolon from the textbox here we go:

PHP:
 Dim empEmails As String 
{...} 
Dim CmdEmailTo As OleDbCommand 
CmdEmailTo = New OleDbCommand(sEmailTo, Conn)
Dim dtrReceiver As OleDbDataReader
dtrReceiver = CmdEmailTo.ExecuteReader
While dtrReceiver.Read()
empEmails &= dtrReceiver("yourField") & ";" 
End While
dtrReceiver.Close()

Dim w AsString = empEmails
w = w.Substring(0, w.Length - 1) 'this will substring everything except last semicolon
Dim objMail As clsMail = New clsMail 
Dim sSendTo As String = w
{...}

Cheers ;)
 
Back
Top