最初,我有一个查询,我将其转换为PDF报告(表格)。但是,现在我想在表中添加另一个查询。 所以我在一列中有一个查询。
我的报告有3列,此查询应位于第三列,因为第一个查询将返回两个值id和name。 我做的第二个问题是关于计算某些东西。
目前我的代码是这样的:
Dim dr As SqlDataReader
command.CommandText = query
command.CommandType = CommandType.Text
command.Connection = con
con.Open()
dr = command.ExecuteReader()
Dim counter = 0
While dr.Read
Dim row As Row = table.AddRow()
row.Format.Alignment = ParagraphAlignment.Center
If counter Mod 2 = 0 Then
row.Shading.Color = TableRowA
Else
row.Shading.Color = TableRowB
End If
counter += 1
row.Cells(0).AddParagraph(counter)
row.Cells(0).Format.Alignment = ParagraphAlignment.Left
row.Cells(0).VerticalAlignment = VerticalAlignment.Bottom
row.Cells(1).AddParagraph(dr.GetString(1))
row.Cells(1).Format.Alignment = ParagraphAlignment.Left
row.Cells(2).AddParagraph(dr.GetInt32(0))
row.Cells(2).Format.Alignment = ParagraphAlignment.Left
row.Cells(3).AddParagraph("")
row.Cells(3).Format.Alignment = ParagraphAlignment.Left
End While
您能告诉我如何更改此代码以添加我在上一栏中的其他查询吗?
我是否必须再次进行While循环?我必须要另一位博士吗?
我做的是:
Dim drquery2 As SqlDataReader
Dim dr As SqlDataReader
command.CommandText = query
command.CommandType = CommandType.Text
command.Connection = con
con.Open()
dr = command.ExecuteReader()
command.CommandText = query2
command.CommandType = CommandType.Text
command.Connection = con
con.Open()
drquery2 = command.ExecuteReader()
Dim counter = 0
While dr.Read
Dim row As Row = table.AddRow()
row.Format.Alignment = ParagraphAlignment.Center
If counter Mod 2 = 0 Then
row.Shading.Color = TableRowA
Else
row.Shading.Color = TableRowB
End If
counter += 1
row.Cells(0).AddParagraph(counter)
row.Cells(0).Format.Alignment = ParagraphAlignment.Left
row.Cells(0).VerticalAlignment = VerticalAlignment.Bottom
row.Cells(1).AddParagraph(dr.GetString(1))
row.Cells(1).Format.Alignment = ParagraphAlignment.Left
row.Cells(2).AddParagraph(dr.GetInt32(0))
row.Cells(2).Format.Alignment = ParagraphAlignment.Left
row.Cells(3).AddParagraph(drquery2.GetInt32(0))
row.Cells(3).Format.Alignment = ParagraphAlignment.Left
End While
这是对的吗?
答案 0 :(得分:-1)
您是否尝试过python3 -m python.project_1.program_1
循环而不是Do...Until
?然后尝试将计数器用作While
(或者可能是4.我已经做了一段时间了,因为我做了这样的事情)