2014-02-14 54 views
0

我试图在文本框中显示两个不同表格中的两个值与一个特定机构的关系。将两个不同列中的两个值显示为一个文本框

我写的代码没有显示“advisor_name”,只显示“Influence_weight_name”。我也希望这两个名称都显示在一行上,所以最终产品应该看起来像这样:顾问名称 - 重量名称

任何人都可以帮忙吗?

下面是我的代码:

Dim totalRecords As Integer = sqlTableInstitution.Rows.Count 
      Dim advisorText As String = "" 
      Dim weightText As String = "" 

      If IsDBNull(sqlTableInstitution.Rows(0)("advisor_name")) <> True Then 
       advisorText = sqlTableInstitution.Rows(0)("advisor_name") 
      End If 

      If IsDBNull(sqlTableInstitution.Rows(0)("Influence_weight_name")) <> True Then 
      weightText = weightText & "-" & sqlTableInstitution.Rows(0)("Influence_weight_name") 
      End If 
Textbox1.text = advisorText 
Textbox1.text = weightText 

回答

1
Private Function GetData() As String 
    Dim totalRecords As Integer = sqlTableInstitution.Rows.Count 
    Dim advisorText As String = "" 
    Dim weightText As String = "" 
    Dim result As String 
    If Not IsDBNull(sqlTableInstitution.Rows(0)("advisor_name")) Then 
    advisorText = sqlTableInstitution.Rows(0)("advisor_name") 
    If Not IsDBNull(sqlTableInstitution.Rows(0)("Influence_weight_name")) Then 
     weightText = sqlTableInstitution.Rows(0)("Influence_weight_name") 
     result = String.Format("{0}-{1}",advisorText, weightText) 
    End If 
    End If 
    Return result 
End Function 
1

这是因为当你到达这条线

Textbox1.text = weightText 

weightTextweightText

尝试更换Textbox1.Text而不将它的替换后续荷兰国际集团代码

Textbox1.text = advisorText 
Textbox1.text = weightText 

与此代码

Textbox1.Text = advisorText & weightText 
相关问题