M
mathew_27
Guest
Hi there I am new to this so can you tell me what am I doing wrong with my data binding to a listview.
Imports System.Data.SqlClient
Public Class My_Movies
Dim cn As New SqlConnection("Data Source=192.168.1.9,49176;Initial Catalog=mbsystems1;Persist Security Info=True;User ID=mbsystemsmathew;Password=Butter1981")
Dim cmd As New SqlCommand
Dim dr As SqlDataReader
Dim sqlquary As String
Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
Add_movie.Show()
End Sub
Private Sub My_Movies_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
TODO: This line of code loads data into the DvdDataSet.Dvd table. You can move, or remove it, as needed.
Me.DvdTableAdapter.Fill(Me.DvdDataSet.Dvd)
End Sub
Private Sub ListView1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ListView1.SelectedIndexChanged
Me.ListView1.Items.Clear()
cn.Open()
With cmd
.Connection = cn
.CommandText = "select * from dvd"
dr = cmd.ExecuteReader
While dr.Read()
With ListView1.Items.Add(dr(1).ToString)
cn.Close()
End With
Thankyou
Continue reading...
Imports System.Data.SqlClient
Public Class My_Movies
Dim cn As New SqlConnection("Data Source=192.168.1.9,49176;Initial Catalog=mbsystems1;Persist Security Info=True;User ID=mbsystemsmathew;Password=Butter1981")
Dim cmd As New SqlCommand
Dim dr As SqlDataReader
Dim sqlquary As String
Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
Add_movie.Show()
End Sub
Private Sub My_Movies_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
TODO: This line of code loads data into the DvdDataSet.Dvd table. You can move, or remove it, as needed.
Me.DvdTableAdapter.Fill(Me.DvdDataSet.Dvd)
End Sub
Private Sub ListView1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ListView1.SelectedIndexChanged
Me.ListView1.Items.Clear()
cn.Open()
With cmd
.Connection = cn
.CommandText = "select * from dvd"
dr = cmd.ExecuteReader
While dr.Read()
With ListView1.Items.Add(dr(1).ToString)
cn.Close()
End With
Thankyou
Continue reading...