0

I have a text box which I search SQL server which returns to values based on the text I pass the SP and then I want to add to the list box items so here is my code below
the DataTable contains the item I want to return in the list, I have used this syntax to populate a Datagrid with no problems, but I can`t seem to add the item in the listbox can anyone help thanks

Dim SPName As SqlCommand
        Dim DbAdapter As New SqlDataAdapter
        Dim DTptntData As New DataTable


        SPName = New SqlCommand("myDB.dbo.Get_Coders_ICD10", EcnConn) 'running a stored procedure
        SPName.CommandType = CommandType.StoredProcedure




        Dim Param1 As SqlParameter = SPName.Parameters.Add("@ICDCode", SqlDbType.Char, 5)
        Param1.Value = txtICD.Text.Trim


        Try

            SPName.Connection.Open()
            SPName.CommandTimeout = 0
            DbAdapter = New SqlDataAdapter(SPName)
            DbAdapter.Fill(DTptntData)
            lstDiag.Items.Add(DTptntData)
           

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
        SPName.Dispose()
        EcnConn.Close()

Edited by Ezzaral: fixed code tags

2
Contributors
2
Replies
5
Views
6 Years
Discussion Span
Last Post by Trebron
0

I fixed it myself thanks anyway I added the below line

lstDiag.Items.Add(DTptntData.Rows(0).Item(0) & "-" & DTptntData.Rows(0).Item(1))

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.