I don't understand how to concatenate in these fields i'm working with, I have a list box and would like to add multiple data to the field instead of the columns field below, I'll list the code, where would I concatenate?
This loads the Data List when the button search is clicked
Sub loaddatalist()
Dim conn As New SqlConnection(ConfigurationSettings.AppSettings("strDBConn"))
Try
conn.Open()
Dim cmd As New SqlCommand("searchtest", conn)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add("@searchword", txtsearchcomments.Text)
cmd.Parameters.Add("@searchword1", txtsearchjack.Text)
cmd.Parameters.Add("@searchword2", txtsearchid.Text)
Dim myAdapter As New SqlDataAdapter(cmd)
Dim ds As New DataSet
myAdapter.Fill(ds)
listbox.DataSource = ds
listbox.DataValueField = "comments"
listbox.DataTextField = "comments"
listbox.DataBind()
Catch ex As Exception
lblerr.Text = ex.Message
End Try
conn.Close()
End Sub
I do not know if this matters but this is when the index of the list box is changed, I don't think it does, but here's what happens when An object is clicked inside the list box
Sub getlistboxitem()
Dim conn As New SqlConnection(ConfigurationSettings.AppSettings("strDBConn"))
Try
conn.Open()
Dim cmd As New SqlCommand("searchlistbox", conn)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add("@comments", listbox.SelectedItem.Text)
Dim reader As SqlDataReader
reader = cmd.ExecuteReader()
If reader.HasRows Then
reader.Read()
txtid.Text = CStr(reader.GetInt32(0))
txtdevicetype.Text = reader.GetString(1) & " "
txtusertype.Text = reader.GetString(2) & " "
txtbldgroom.Text = reader.GetString(3) & " "
txtswitchname.Text = reader.GetString(4) & " "
txtvlan.Text = reader.GetString(5) & " "
txtblade.Text = CStr(reader.GetInt32(6)) & " "
txtport.Text = CStr(reader.GetInt32(7)) & " "
txtjack.Text = reader.GetString(8) & " "
txtipdn.Text = CStr(reader.GetInt32(9)) & " "
txttelco.Text = reader.GetString(10) & " "
txtdevice.Text = reader.GetString(11) & " "
txtdatemade.Text = reader.GetString(12) & " "
txtcomments.Text = reader.GetString(13) & " "
End If
Catch ex As Exception
lblerr.Text = ex.Message
End Try
conn.Close()
loaddatagrid2()
End Sub