我调用了一个数据库,在该数据库中它获取了一个以管道分隔的字符串,我将其分解为一个数组并填充文本框,这个确切的代码适用于除此之外的所有其他实例,我可以找出原因。此实例仅将字符串的前两个字母打印到两个文本框中
来自查询的数据看起来像这样“这是一个测试|这是一个测试”
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”的值,而 textbox b 取“h”的值 “this is a test|this is a test”的前两个字母
这件几乎相同的作品
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