Hey i have a form that has a listview that has a list of saved slide shows
Code:Public showID As Integer Public showTitle As String Public showOwner As String Private Sub FormMySlideShow_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim mySqlCommand As sqlcommand = New SqlCommand mySqlCommand.CommandType = CommandType.Text mySqlCommand.Connection = SqlConnection1 mySqlCommand.CommandType = CommandType.Text mySqlCommand.CommandText = "SELECT showID, showTitle, showOwner FROM shows WHERE showOwner LIKE @showOwner;" mySqlCommand.Parameters.Add(New SqlParameter("@showOwner", SqlDbType.VarChar)) mySqlCommand.Parameters("@showOwner").Value = System.Environment.UserName Try mySqlCommand.Connection.Open() Dim myDataReader As SqlDataReader myDataReader = mySqlCommand.ExecuteReader(CommandBehavior.Default) While myDataReader.Read Dim item As ListViewItem = New ListViewItem showID = myDataReader.GetValue(0) showTitle = myDataReader.GetValue(1) showOwner = myDataReader.GetValue(2) item.Text = showTitle item.Tag = showTitle Me.ListViewShows.Items.Add(item) End While Catch ex As Exception MessageBox.Show(ex.Message) End Try SqlConnection1.Close() End Sub
what i want to do is fill a collection called pictures in another form called FormShowPreview using an sql SELECT command to filter the records i want into the collection
i think i will have to pass the content of a datareader to the Collection but i am not sure
here is my code so far:
ThanksCode:Private Sub ButtonSlideShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonSlideShow.Click Dim FormShowPreviewOpen As New FormShowPreview Dim mySqlCommand As SqlCommand = New SqlCommand mySqlCommand.CommandType = CommandType.Text mySqlCommand.Connection = SqlConnection1 mySqlCommand.CommandType = CommandType.Text mySqlCommand.CommandText = "SELECT [shows].[showID], [shows].[showTitle], [shows].[showOwner], [showSlides].[showID], [showSlides].[pictureID], [showSlides].[pictureOrder] FROM [shows], [showSlides] WHERE (([shows].[showTitle] = @showTitle) AND ([shows].[showOwner] = @showOwner));" mySqlCommand.Parameters.Add(New SqlParameter("@showTitle", SqlDbType.Text)) mySqlCommand.Parameters("@showTitle").Value = ListViewShows.Text mySqlCommand.Parameters.Add(New SqlParameter("@showOwner", SqlDbType.Text)) mySqlCommand.Parameters("@showOwner").Value = System.Environment.UserName Try SqlConnection1.Open() Dim myDataReader As SqlDataReader myDataReader = mySqlCommand.ExecuteReader(CommandBehavior.Default) ============================================ not sure how to add the queried information to the collection in the FormPreviewShow ============================================ Catch ex As Exception MessageBox.Show(ex.Message) Finally mySqlCommand.Connection.Close() FormShowPreviewOpen.ShowDialog() End Try End Sub




Reply With Quote