使用 Powershell v1.0,如何将 DataSet 中的数据添加到字符串中?
With Powershell v1.0, How do I add the data inside a DataSet to a string?
我想将 DataSet 对象中的数据添加到现有字符串中。
当前代码:
$Dataset.Tables[0] | foreach {
$_
}
Returns:
但是当我尝试将此数据添加到字符串时,我没有添加任何内容。
$emailBody = "ALERT!: The following errors were found - `n"
$Dataset.Tables[0] | foreach {
$emailBody += <I don't know what to put here>
}
如何获取 DataSet 中的结果并将它们添加到此字符串中?
参考Link:How to loop through a dataset in Powershell
在改变我构建问题的方式时,我在相关 post 中找到了问题的答案,可以通过上面的 link 访问。
答案:
$emailBody = "ALERT!: The following errors were found - `n"
foreach ($Row in $Dataset.Tables[0].Rows)
{
$emailBody += "$($Row[0]) `n"
}
结果:
它列出了从数据库中提取并添加到 DataSet 对象到字符串中的数据。
我想将 DataSet 对象中的数据添加到现有字符串中。
当前代码:
$Dataset.Tables[0] | foreach {
$_
}
Returns:
但是当我尝试将此数据添加到字符串时,我没有添加任何内容。
$emailBody = "ALERT!: The following errors were found - `n"
$Dataset.Tables[0] | foreach {
$emailBody += <I don't know what to put here>
}
如何获取 DataSet 中的结果并将它们添加到此字符串中?
参考Link:How to loop through a dataset in Powershell
在改变我构建问题的方式时,我在相关 post 中找到了问题的答案,可以通过上面的 link 访问。
答案:
$emailBody = "ALERT!: The following errors were found - `n"
foreach ($Row in $Dataset.Tables[0].Rows)
{
$emailBody += "$($Row[0]) `n"
}
结果:
它列出了从数据库中提取并添加到 DataSet 对象到字符串中的数据。