我有一个数据库的调用,它获取一个管道分隔的字符串,我打破一个数组并填充文本框,这个确切的代码适用于除此之外的每个其他实例,我可以找出原因。此实例仅将字符串的前两个字母打印到两个文本框中
来自查询的数据看起来像这样“这是一个测试|这是一个测试”
Dim queryString3 As String = "SELECT Answer FROM ShortAnswers where questionNumber = 12 and submission = 1375"
Using connection As New SqlConnection(My.Settings.ConnString)
Dim command As New SqlCommand(queryString3, connection)
connection.Open()
Dim rdr As String = command.ExecuteScalar()
Dim P3 As String
P3 = rdr
Dim Part3 As New ArrayList(P3.Split("|"c))
TextBoxA.Text = Part3(0)
TextBoxB.Text = Part3(1)
在此示例中,textboxa取值为“t” 和文本框b取值“h” “这是一个测试|这是一个测试”的前两个字母
这个几乎相同的作品
Dim queryString As String ="SELECT Answer FROM ShortAnswers where questionNumber = 11 and submission = 1375"
Using connection As New SqlConnection(My.Settings.OnLineTestingDB)
Dim command2 As New SqlCommand(queryString, connection)
connection.Open()
Dim rdr1 As String = command2.ExecuteScalar()
Dim P2 As String
P2 = rdr1
Dim Part2 As New ArrayList(P2.Split("|"c))
Normal.Text = Part2(0)
Normal1.Text = Part2(1)
Normal2.Text = Part2(2)
End Using
答案 0 :(得分:1)
问题在于是从字符串而不是数组
中获取字符串Dim Part3 As New ArrayList(P3.Split("|"c))
TextBoxA.Text = P3(0)
TextBoxB.Text = P3(1)
现在看起来像
Dim Part3 As New ArrayList(P3.Split("|"c))
TextBoxA.Text = Part3(0)
TextBoxB.Text = Part3(1)
纠正了这个问题,谢谢你的帮助,有时候你需要一双额外的眼睛来唤醒你