简体   繁体   中英

Same convention working for all other instances but this one

I have a call to a database where it gets a pipe delimited string which i break into an array and fill text boxes, this exact code works for every other instance except this one, and i can figure out why. this instances only prints the first two letters of the string into the two textboxes

the data that would come from the query looks like this "this is a test|this is a test"

    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)

in this example textboxa takes the value of "t" and textbox b takes the value of "h" the first two letters from "this is a test|this is a test"

this nearly identical piece works

    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

The issue was that is was taking the charatcters from the string not the array

Dim Part3 As New ArrayList(P3.Split("|"c))
   TextBoxA.Text = P3(0)
   TextBoxB.Text = P3(1)

it now looks like

Dim Part3 As New ArrayList(P3.Split("|"c))
   TextBoxA.Text = Part3(0)
   TextBoxB.Text = Part3(1)

which corrected the issue, thank you for your help, sometimes you just need an extra set of eyes to wake you up

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM