Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 02-01-2006, 09:11 AM   #1 (permalink)
rikb53
Registered User
 
Join Date: Jan 2006
Posts: 29
rikb53 is on a distinguished road
DataRow Iteration

Guys if anyone has an answer to this - i'd appreciate some assistance.
the problem is not building the dataset within String Builder - so i can render it as HTML in the email msg body.
the problem is - the dataset can change and return more or less columns than i have here and my DataRows, Im specifing
certain Indexes.
so, one time the dataset will have say, 5 rows in it and the next time it may have say 12. i'm about at the edge of my expertise right now, so any code examples from an expert would be appreciated - other wise the only thing i can think of is to
build separate Stringbuilder Components and pass a number to them that corresponds with the number of columns retrieved.
i've only included enough of the snippets of code in the procedure - to give clarity. i can send all if need be, but the real problem is in the aRow.Item("index")
thanks again for any help.
rik

Public ds As DataSet
Dim oMailMsg As MailMessage = New MailMessage
Dim sb As New StringBuilder
oMailMsg.BodyFormat = MailFormat.Html

sb.Append("<p><img SRC=C:\SelectLogo.gif></p><br>")
For Each aRow In ds.Tables(0).Rows
sb.Append("<table border=1 cellspacing=3><tr><td>" + aRow.Item(0) + "</td>" + "<td>" + aRow.Item(1) + "</td></tr></table>")
Next
oMailMsg.Body = sb.ToString
SmtpMail.Send(oMailMsg)
rikb53 is offline   Reply With Quote
Old 02-17-2006, 06:46 PM   #2 (permalink)
iowacb4600f4guy
Registered User
 
Join Date: Feb 2006
Location: Clive, iowa
Posts: 3
iowacb4600f4guy is on a distinguished road
Send a message via AIM to iowacb4600f4guy
Quote:
Originally Posted by rikb53
Guys if anyone has an answer to this - i'd appreciate some assistance.
the problem is not building the dataset within String Builder - so i can render it as HTML in the email msg body.
the problem is - the dataset can change and return more or less columns than i have here and my DataRows, Im specifing
certain Indexes.
so, one time the dataset will have say, 5 rows in it and the next time it may have say 12. i'm about at the edge of my expertise right now, so any code examples from an expert would be appreciated - other wise the only thing i can think of is to
build separate Stringbuilder Components and pass a number to them that corresponds with the number of columns retrieved.
i've only included enough of the snippets of code in the procedure - to give clarity. i can send all if need be, but the real problem is in the aRow.Item("index")
thanks again for any help.
rik

Public ds As DataSet
Dim oMailMsg As MailMessage = New MailMessage
Dim sb As New StringBuilder
oMailMsg.BodyFormat = MailFormat.Html

sb.Append("<p><img SRC=C:\SelectLogo.gif></p><br>")
For Each aRow In ds.Tables(0).Rows
sb.Append("<table border=1 cellspacing=3><tr><td>" + aRow.Item(0) + "</td>" + "<td>" + aRow.Item(1) + "</td></tr></table>")
Next
oMailMsg.Body = sb.ToString
SmtpMail.Send(oMailMsg)
I am not 100% clear what you are looking for as your post mentions that the rows and columns were your problem. The rows shouldn't be an issue.

The dataset.table object has a "Columns" property that allows you to get a count of the columns. You can then create another loop inside of your for each loop to write out the columns.

If you need some detailed help, post back up or e-mail me and I can see what I can do!
iowacb4600f4guy is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 07:06 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting