0

hi.. i'm new in using vb... can anybody help me to check the problem inside my code?

Imports System.Data.OleDb
Imports System.IO


Public Class editMovies

    Private Sub editMovies_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim con As OleDbConnection = New OleDbConnection(conString)
        Dim cmd As OleDbCommand = New OleDbCommand("SELECT movie FROM nowShowing", con)
        con.Open()
        Dim myDA As OleDbDataAdapter = New OleDbDataAdapter(cmd)
        Dim myDataSet As DataSet = New DataSet()
        myDA.Fill(myDataSet, "nowShowing")

        movieComboBox.DataSource = myDataSet.Tables("nowShowing").DefaultView
        movieComboBox.ValueMember = "movie"
        movieComboBox.DisplayMember = "movie"

        con.Close()
        con = Nothing
    End Sub

    Private Sub saveButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles saveButton.Click
        Dim fsreader As New FileStream(OpenFileDialog1.FileName, FileMode.Open, FileAccess.Read)
        Dim breader As New BinaryReader(fsreader)
        Dim imgbuffer(fsreader.Length) As Byte
        breader.Read(imgbuffer, 0, fsreader.Length)
        fsreader.Close()

        strsql = "UPDATE into nowShowing (movie,poster,synopsis, trailer) values (@dtamovie, @dtaposter, @dtasynopsis, @dtatrailer,)"
        cmd.CommandText = strsql
        cmd.Connection = conn
        cmd.Parameters.AddWithValue("@dtamovie", MovieTextBox.Text)
        cmd.Parameters.AddWithValue("@dtaposter", imgbuffer)
        cmd.Parameters.AddWithValue("@dtasynopsis", SynopsisTextBox.Text)
        cmd.Parameters.AddWithValue("@dtatrailer", trailerTextBox.Text)
        cmd.ExecuteNonQuery()
        cmd.Dispose()
        MsgBox("Record successfully saved...", MsgBoxStyle.Information)

        conn.Close()
        fileNameTextBox.Clear()
        PosterPictureBox.Image = Nothing
        trailerTextBox.ReadOnly = True
        SynopsisTextBox.ReadOnly = True
        fileNameTextBox.ReadOnly = True

    End Sub


    Private Sub searchButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles searchButton.Click
        strsql = "SELECT * FROM nowShowing WHERE movie = '" & movieComboBox.Text & "'"
        cmd.CommandText = strsql
        cmd.Connection = conn
        
        PosterPictureBox = dr("poster")
        MovieTextBox.Text = dr("movie").ToString()
        SynopsisTextBox.Text = dr("synopsis").ToString()
        trailerTextBox.Text = dr("trailer").ToString()

        
        cmd.ExecuteNonQuery()
        cmd.Dispose()
        conn.Close()

        
        
    End Sub


    Private Sub editButton_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles editButton.Click
        trailerTextBox.ReadOnly = False
        SynopsisTextBox.ReadOnly = False
        fileNameTextBox.ReadOnly = False
    End Sub

    Private Sub browseButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles browseButton.Click
        OpenFileDialog1.ShowDialog()
        fileNameTextBox.Text = OpenFileDialog1.FileName
        PosterPictureBox.Image = Image.FromFile(fileNameTextBox.Text)
    End Sub
End Class
1
Contributor
1
Reply
2
Views
5 Years
Discussion Span
Last Post by klm910622
0

hi.. i'm new in using vb... can anybody help me to check the problem inside my code?

Imports System.Data.OleDb
Imports System.IO


Public Class editMovies

    Private Sub editMovies_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim con As OleDbConnection = New OleDbConnection(conString)
        Dim cmd As OleDbCommand = New OleDbCommand("SELECT movie FROM nowShowing", con)
        con.Open()
        Dim myDA As OleDbDataAdapter = New OleDbDataAdapter(cmd)
        Dim myDataSet As DataSet = New DataSet()
        myDA.Fill(myDataSet, "nowShowing")

        movieComboBox.DataSource = myDataSet.Tables("nowShowing").DefaultView
        movieComboBox.ValueMember = "movie"
        movieComboBox.DisplayMember = "movie"

        con.Close()
        con = Nothing
    End Sub

    Private Sub saveButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles saveButton.Click
        Dim fsreader As New FileStream(OpenFileDialog1.FileName, FileMode.Open, FileAccess.Read)
        Dim breader As New BinaryReader(fsreader)
        Dim imgbuffer(fsreader.Length) As Byte
        breader.Read(imgbuffer, 0, fsreader.Length)
        fsreader.Close()

        strsql = "UPDATE into nowShowing (movie,poster,synopsis, trailer) values (@dtamovie, @dtaposter, @dtasynopsis, @dtatrailer,)"
        cmd.CommandText = strsql
        cmd.Connection = conn
        cmd.Parameters.AddWithValue("@dtamovie", MovieTextBox.Text)
        cmd.Parameters.AddWithValue("@dtaposter", imgbuffer)
        cmd.Parameters.AddWithValue("@dtasynopsis", SynopsisTextBox.Text)
        cmd.Parameters.AddWithValue("@dtatrailer", trailerTextBox.Text)
        cmd.ExecuteNonQuery()
        cmd.Dispose()
        MsgBox("Record successfully saved...", MsgBoxStyle.Information)

        conn.Close()
        fileNameTextBox.Clear()
        PosterPictureBox.Image = Nothing
        trailerTextBox.ReadOnly = True
        SynopsisTextBox.ReadOnly = True
        fileNameTextBox.ReadOnly = True

    End Sub


    Private Sub searchButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles searchButton.Click
        strsql = "SELECT * FROM nowShowing WHERE movie = '" & movieComboBox.Text & "'"
        cmd.CommandText = strsql
        cmd.Connection = conn
        
        PosterPictureBox = dr("poster")
        MovieTextBox.Text = dr("movie").ToString()
        SynopsisTextBox.Text = dr("synopsis").ToString()
        trailerTextBox.Text = dr("trailer").ToString()

        
        cmd.ExecuteNonQuery()
        cmd.Dispose()
        conn.Close()

        
        
    End Sub


    Private Sub editButton_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles editButton.Click
        trailerTextBox.ReadOnly = False
        SynopsisTextBox.ReadOnly = False
        fileNameTextBox.ReadOnly = False
    End Sub

    Private Sub browseButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles browseButton.Click
        OpenFileDialog1.ShowDialog()
        fileNameTextBox.Text = OpenFileDialog1.FileName
        PosterPictureBox.Image = Image.FromFile(fileNameTextBox.Text)
    End Sub
End Class

the problem is when i press search, nothing is coming out. and there's a error line on 'PosterPictureBox = dr("poster")'... can anyone help me to fixed it? Thank you.

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.