Click to See Complete Forum and Search --> : how send datatable's data by email
husky_doggy
Jan 22nd, 2009, 04:52 PM
i want to email all the data from a datatable from another form.
is there a way i can get all the data at once?
and if I want to sortorder the date in the datagrid, what should I put in the query builder??
Private Sub emailbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles emailbtn.Click
Dim message As New EmailMessage
message.Subject = "test email"
message.BodyText = ' all data here<<<<
Dim client As New Recipient("ABD", "ABC@googlemail.com")
message.To.Add(client)
Dim emailsession As New OutlookSession
emailsession.EmailAccounts("GoogleMail").Send(message)
MsgBox("email sent")
End Sub
petevick
Jan 23rd, 2009, 08:48 AM
I think you will have to read the datatable and put the contents in the body.
To sort on a Sql retrieval use 'order by' - is that what you mean?
husky_doggy
Jan 23rd, 2009, 10:18 AM
I think you will have to read the datatable and put the contents in the body.
To sort on a Sql retrieval use 'order by' - is that what you mean?
i mean (for example. search in a table would be : LIKE @lastname +'%')
so what do I put on the " sort by " to achieve sort according to date?
petevick
Jan 24th, 2009, 02:02 AM
order by mydatename
husky_doggy
Jan 24th, 2009, 06:52 AM
SELECT [Recorded date], [Food Intake], Image
FROM foodjournal
ORDER BY [Recorded date] DESC
this is what i put, but it doesnt seems to work.
petevick
Jan 25th, 2009, 01:03 AM
Do you get a syntax error, is it not sorted - how does it not seem to work??
Try the same syntax on the device in query analyzer
husky_doggy
Jan 25th, 2009, 01:45 PM
Do you get a syntax error, is it not sorted - how does it not seem to work??
Try the same syntax on the device in query analyzer
ok ...i done it...just a little bit of mistake...
back to the read datatable question...
i am trying to use sqldatareader to read them.
so that means i need to establishing the connection right?
and i wonder what is the data source equals to? my filepath for the .sdf file?
is this the connection string correct?
myConnection = New SqlConnection("Data Source=" & "Initial Catalog=appdatabase1;" & _
"Integrated Security=SSPI")
petevick
Jan 25th, 2009, 02:18 PM
Surely you have filled the datatable from the database - do you now not just want to read the datatable?
husky_doggy
Jan 25th, 2009, 02:43 PM
Surely you have filled the datatable from the database - do you now not just want to read the datatable?
yes, sure I filled the table. but what I mean by reading the data is not displaying them in the grid.
as my initial question was to send those data out by email, so I need to read those data and put it in a string variable. then send it out by email right?
petevick
Jan 25th, 2009, 03:32 PM
Why not just read from the database, construct a string, and email the string?
husky_doggy
Jan 25th, 2009, 03:43 PM
Why not just read from the database, construct a string, and email the string?
isnt this just same as what i try to do??
petevick
Jan 26th, 2009, 01:06 AM
So what is the datagrid all about then?
husky_doggy
Jan 26th, 2009, 02:26 AM
So what is the datagrid all about then?
it is because I have this datagrid on form1 and I enter data there...
then I wanted to read all that data from that grid and send it out on form2
petevick
Jan 26th, 2009, 09:18 AM
So now I am totally confused - where does the datatable and SQL come into things.
You can process the grid by reading each row and column in turn, and appending to a string.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.