【发布时间】:2012-04-26 04:24:26
【问题描述】:
我正在编写一个电子邮件应用程序,用于向客户发送 HTML 新闻文章。 我正在使用数据集返回要显示给客户的标题。当我遍历数据集时,会返回最新的记录,但不会显示最新的标题链接。所以输出的 HTML 每次都是同一个标题,是数据集中的第一条记录。如何移动到数据集中的下一条记录并获取输出的 HTML 以显示下一个/正确的标题?
这是我的代码示例:
'填充数据集的代码
公共函数 GetHeadline(ByVal ArticleID As Integer) As DataSet
Try
Dim objConn As SqlConnection = New SqlConnection()
objConn.ConnectionString = myConnectionString
objConn.Open()
ds = New DataSet
ds.Clear()
Dim sqlCommand As String = "SomeSql"
Dim objCmd As SqlCommand = New SqlCommand(sqlCommand, objConn)
Dim dataAdapter As SqlDataAdapter = New SqlDataAdapter(objCmd)
dataAdapter.Fill(ds)
Catch ex As Exception
MsgBox(ex.ToString)
GetHeadline = Nothing
End Try
Return ds
End Function
'填充链接的代码
If GroupID = 4 Then
iLocation1 = HTMLbody.IndexOf("{!HeadlineID")
While iLocation1 > 0
iLocation2 = HTMLbody.IndexOf("}", iLocation1)
sHeadLineTag = HTMLbody.Substring(iLocation1 + 1, iLocation2 - iLocation1 - 1)
dtReport = clsGlobal.globalReportCatalog.GetHeadline2()
clsGlobal.globalReportCatalog.SetHeadlinePropertiesFromRow(dtReport.Rows(0))
With clsGlobal.globalReportCatalog
For i As Integer = 0 To dtReport.Rows.Count
If i < dtReport.Rows.Count - 1 Then
i = i + 1
End If
Dim ID As Integer = dtReport.Rows(i)("ArticleID")
sHyperTag = "<a href=""" & "http://www.myweb.com/somedirectory/Login.aspx" & .HeadlineMarketingLink & """>" & .HeadlineReportName & " - " & .HeadlineTitle & "</a>"
sHeadlineDescription = .HeadlineDescription
HTMLbody = HTMLbody.Replace("{!Report.Description}", sHeadlineDescription)
Next
End With
【问题讨论】: