How to get values from listview and display it to textbox using sql database ?
and then i can update the items in listview using a button..then refresh the listview
after i click the button...

tnx for the help in advance..im just a newbie in vb.net 0da2d193278007986792bf92e19433ab

Post your code. how far you doing this.

This following code to get items on listview and show it in textboxes

Private Sub ListView1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.Click
    Dim x As Integer = CInt(ListView1.SelectedItems(0).Index)

    TextBox1.Text = ListView1.Items(x).SubItems(0).Text
    TextBox2.Text = ListView1.Items(x).SubItems(1).Text
End Sub

in my other form i did the saving thing from textbox to database..and retrieve the data throught listview..now what i want is..to get that items from listview and display it to texbox and can update the data by clicking the button and refreshes the listview which i can't get through cause i dont know what to do...

I was give you the answer about getting items on listview in previous post.
How about post your update code?

If ListView1.SelectedItems.Count > 0 Then
            conn.Open()
            With com
                .Connection = conn
                .CommandText = "SELECT * FROM ItemTBL "
                .CommandType = CommandType.Text
            End With
            rdr = com.ExecuteReader
            While rdr.Read
                AddTXT.Text = rdr("Stock")
            End While
            rdr.Close()
            conn.Close()

thats my code..i did manage to click an item from listview in display it to textbox but my problem is...it only displays the last record...why is that ?

but my problem is...it only displays the last record...why is that ?

Actualy, your code show the entire data but it will show you the last record because you use textbox to show it. Textbox value will replace with current record in looping and the end it will replace with last record.
If you change the line 10 with combobox (Combobox1.Items.Add (rdr("Stock")) then you will see the entire records.

But why you bind it again to database if you just want to display the selected item on listview?
Just use the code that i give to you above..
After you fill listview with data from database then use this following code to show selected item on listview.

Private Sub ListView1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.Click
    Dim x As Integer = CInt(ListView1.SelectedItems(0).Index)

    TextBox1.Text = ListView1.Items(x).SubItems(0).Text
    TextBox2.Text = ListView1.Items(x).SubItems(1).Text
End Sub

i need to create a project using vb.net and sql as the server
in my project i have th buttons save, edit, delite, and view.
add button to add the data inputed in the textboxes to the database
view to show the data in the database to my listview
edit to edit data delete to delete data
to edit and delete i need to select the data in the listview and put it back to the text boxes
can someone give me some codes i am new in programming and it is very difficult to find usefull codes thank you very much

Public Sub selectStock()
        Try
            conn.ConnectionString = myConnection
            If conn.State = ConnectionState.Closed Then
                conn.Open()
            End If

            Dim myQuery As String = "SELECT * FROM StockItem WHERE itemBarcode = @barcode "
            Dim cmd As New OleDbCommand
            With cmd
                .CommandText = myQuery
                .Connection = conn
                .Parameters.AddWithValue("@itemBarcode", ScanCode.Text)
                .ExecuteNonQuery()

                While .ExecuteReader.Read
                    showItem.AppendText(vbTab + " ------------------------ " + vbNewLine)
                    showItem.AppendText(vbTab + " Asalura Catering Service " + vbNewLine)
                    showItem.AppendText(vbTab + " ------------------------ " + vbNewLine)
                    showItem.AppendText(vbTab + " Asalura Catering Service " + vbNewLine)
                    showItem.AppendText(vbTab + " Asalura Catering Service " + vbNewLine)
                    showItem.AppendText(vbTab + " Asalura Catering Service " + vbNewLine)
                    showItem.AppendText(vbTab + " Asalura Catering Service " + vbNewLine)
                    showItem.AppendText(vbTab + " Asalura Catering Service " + vbNewLine)
                End While
            End With

        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
        conn.Close()
    End Sub

also i too am having the same issue but i need the showItem to display the particular id when requested

Please i need a way i can pull out the data row from the database into the showItem textbox

First of all you don't hijack other people's post. You need to create yours as I don't think these questions are similar. Secondly what is ShowItem I mean is it a variable, a control tool? Why I ask this is because if its a variable you could have diclared it as an Array variable so that it will be easy to point to the ID you want.

Also I'm not sure of this ShowItem to what it is, again if its a variable you can also loop through it and get the text contained inside if its a COLLECTION and check the currently focused index if it contains the same Id as that you are looking for.

With little or no detaits its not easy to help you with your question as well.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.