Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27554

VS 2010 Listview only gives ID in return

$
0
0
Dear all

I created a listview and the only Item I get into this window is the ID of my db.
if I check if the while is correctly implemented I can see that All the info of the given ID is presented correctly, can anyone help me on how to solve this

Code:

Public Class Form1
    Sub FillComboOs()
        strsql = "select * from Os"
        Dim acscmd As New OleDb.OleDbCommand
        acscmd.CommandText = strsql
        acscmd.Connection = acsconn
        acsdr = acscmd.ExecuteReader
        While (acsdr.Read())
            CbxOs.Items.Add(acsdr("Windows"))
        End While
        acscmd.Dispose()
        acsdr.Close()
    End Sub
    Sub FillComboOffice()
        strsql = "select * from Office"
        Dim acscmd As New OleDb.OleDbCommand
        acscmd.CommandText = strsql
        acscmd.Connection = acsconn
        acsdr = acscmd.ExecuteReader
        While (acsdr.Read())
            CbxOffice.Items.Add(acsdr("OfficeVersion"))
        End While
        acscmd.Dispose()
        acsdr.Close()
    End Sub
    Sub FillComboInstall()
        strsql = "select * from installtype"
        Dim acscmd As New OleDb.OleDbCommand
        acscmd.CommandText = strsql
        acscmd.Connection = acsconn
        acsdr = acscmd.ExecuteReader
        While (acsdr.Read())
            CbxInstal.Items.Add(acsdr("installed"))
        End While
        acscmd.Dispose()
        acsdr.Close()
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        modCon.connect()
        Me.FillComboOs()
        Me.FillComboOffice()
        Me.FillComboInstall()
        Me.filllsitview()
    End Sub

    Private Sub BtnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnAdd.Click
        'sqlstatements
        strsql = "insert into TelelinkTable (Datum, ContactPerson, ContactPhone, IsaAbo, IsaAdminUser, Os, Os64, Office, Of64, InstallType, Remarks) values ('" _
            & DateTimePicker1.Text & "','" _
            & txtContact.Text & "','" _
            & txtPhone.Text & "','" _
            & txtIsaAbo.Text & "','" _
            & TxtIsaAdmin.Text & "','" _
            & CbxOs.Text & "','" _
            & RdbOs64.Text & "','" _
            & CbxOffice.Text & "','" _
            & RdbOf64.Text & "','" _
            & CbxInstal.Text & "','" _
            & txtRemark.Text & "')"

        Dim acscmd As New OleDb.OleDbCommand ' the oledbcommand
        acscmd.CommandText = strsql 'sets the sql string
        acscmd.Connection = acsconn 'sets the connection to use the oledbcommand
        acscmd.ExecuteNonQuery() ' execute oledb commands non query only
        acscmd.Dispose()
        MsgBox("Saved")
        'Me.filllsitview()
    End Sub

    Sub filllsitview()
        'sql statements
        strsql = "select * from TelelinkTable"
        Dim acscmd As New OleDb.OleDbCommand
        acscmd.CommandText = strsql
        acscmd.Connection = acsconn
        acsda.SelectCommand = acscmd
        acsdr = acscmd.ExecuteReader()

        'clear the listview
        ListView1.Items.Clear()
        'display the result of the query into the listview
        While (acsdr.Read())
            With ListView1.Items.Add(acsdr("Id"))
                .subitems.add(acsdr("Datum"))
                .subitems.add(acsdr("ContactPerson"))
                .subitems.add(acsdr("ContactPhone"))
                .subitems.add(acsdr("IsaAbo"))
                .subitems.add(acsdr("IsaAdminUser"))
                .subitems.add(acsdr("Os"))
                .subitems.add(acsdr("Os64"))
                .subitems.add(acsdr("Office"))
                .subitems.add(acsdr("Of64"))
                .subitems.add(acsdr("InstallType"))
                .subitems.add(acsdr("Remarks"))
            End With
        End While
        acscmd.Dispose()
        acsdr.Close()


    End Sub
    Private Sub ListView1_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseDoubleClick
        'displays the details from the listview to the textbox
        With ListView1.SelectedItems(0)
            txtid.Text = .SubItems(0).Text
            DateTimePicker1.Text = .SubItems(1).Text
            txtContact.Text = .SubItems(2).Text
            txtPhone.Text = .SubItems(3).Text
            txtIsaAbo.Text = .SubItems(4).Text
            TxtIsaAdmin.Text = .SubItems(5).Text
            CbxOs.Text = .SubItems(7).Text
            RdbOs64.Text = .SubItems(8).Text
            CbxOffice.Text = .SubItems(9).Text
            RdbOf64.Text = .SubItems(10).Text
            CbxInstal.Text = .SubItems(11).Text
            txtRemark.Text = .SubItems(12).Text

        End With
    End Sub
   


    Private Sub txtIsaAbo_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtIsaAbo.TextChanged
        searchrecord(txtIsaAbo.Text)
    End Sub

    Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged

    End Sub

    Sub searchrecord(ByVal searchword As String)
        'sql statements
        strsql = "select * from TelelinkTable where IsaAbo like '" & searchword & "%'"
        Dim acscmd As New OleDb.OleDbCommand
        acscmd.CommandText = strsql
        acscmd.Connection = acsconn
        acsda.SelectCommand = acscmd
        acsdr = acscmd.ExecuteReader
        'clear the listview
        ListView1.Items.Clear()
        While (acsdr.Read())
            With ListView1.Items.Add(acsdr("Id"))
                .subitems.add(acsdr("Datum"))
                .subitems.add(acsdr("ContactPerson"))
                .subitems.add(acsdr("ContactPhone"))
                .subitems.add(acsdr("IsaAbo"))
                .subitems.add(acsdr("IsaAdminUser"))
                .subitems.add(acsdr("Os"))
                .subitems.add(acsdr("Os64"))
                .subitems.add(acsdr("Office"))
                .subitems.add(acsdr("Of64"))
                .subitems.add(acsdr("InstallType"))
                .subitems.add(acsdr("Remarks"))
            End With
        End While
        acscmd.Dispose()
        acsdr.Close()

    End Sub

    Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
        Me.Close()

    End Sub
End Class


Viewing all articles
Browse latest Browse all 27554

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>