Click here to Skip to main content
15,887,356 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i tried this code but the ex.message being given is "Parameter not found" and the picture is not being loaded into the picturebox designpic

What I have tried:

Imports System.Data.OleDb
Imports System.IO

Public Class Designs
    Dim conn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\DATABASE.accdb")
    Dim dr As OleDbDataReader
    Dim flag As Boolean
    Dim dt As DataTable
    Dim da As OleDbDataAdapter
    Dim a As Integer
    Dim count As Integer
    Private Sub txt_strips_TextChanged(sender As Object, e As EventArgs)

    End Sub
    Sub count1()

        conn.Open()
        Dim cmd As New OleDb.OleDbCommand("select count (*) from Catelog", conn)
        count = cmd.ExecuteScalar

        conn.Close()
    End Sub

    Private Sub chc_flower_CheckedChanged(sender As Object, e As EventArgs) Handles chc_flower.CheckedChanged

    End Sub

    Private Sub chc_logo_CheckedChanged(sender As Object, e As EventArgs) Handles chc_logo.CheckedChanged

    End Sub
    Sub GETMYID()
        
        Try
            conn.Open()
            Dim cmd As New OleDbCommand("Select * from Catelog", conn)
            da = New OleDbDataAdapter
            dt = New DataTable

            da.SelectCommand = cmd
            da.Fill(dt)

            Guna2TextBox1.Text = dt.Rows(a).Item("ID")
            txt_design.Text = txt_design.PlaceholderText & ": " & dt.Rows(a).Item("Design")
            _Sales.lbl_design.Text = dt.Rows(a).Item("Design")
            check_head.Checked = dt.Rows(a).Item("Headstone")
            txt_head.Text = txt_head.PlaceholderText & ": " & dt.Rows(a).Item("Headstone_size")
            chc_ledger.Checked = dt.Rows(a).Item("Ledger")
            txt_ledger.Text = txt_ledger.PlaceholderText & ": " & dt.Rows(a).Item("Ledger_size")
            chc_strips.Checked = dt.Rows(a).Item("Strips")
            txt_strips.Text = txt_strips.PlaceholderText & ": " & dt.Rows(a).Item("Strips_size")
            chc_vases.Checked = dt.Rows(a).Item("Vases")
            chc_pavers.Checked = dt.Rows(a).Item("Pavers")
            chc_flower.Checked = dt.Rows(a).Item("Flower_boarderline")
            chc_logo.Checked = dt.Rows(a).Item("Logo_emblem")
            chc_pic.Checked = dt.Rows(a).Item("Picture")
            cmb_picsize.Text = dt.Rows(a).Item("Picture_size")
            txt_price.Text = txt_price.PlaceholderText & ": USD $" & dt.Rows(a).Item("Price")
            _Sales.lbl_price.Text = dt.Rows(a).Item("Price")
            txt_colour.Text = txt_colour.PlaceholderText & ": " & dt.Rows(a).Item("Colour")

            Dim picture As Byte
            designpic.Image = Nothing

            picture = dt.Rows(a).Item("Picture_design")
            Dim mstream As New System.IO.MemoryStream(picture)
            designpic.Image = Image.FromStream(mstream)

        Catch ex As Exception

        End Try
        conn.Close()
        
    End Sub


    Private Sub cmb_picsize_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cmb_picsize.SelectedIndexChanged

    End Sub

    Private Sub Designs_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        a = 0
        count1()
        GETMYID()
        If a = 0 Then
            img_back.Visible = False
        Else
            img_back.Visible = True
        End If

    End Sub
    Private Sub Guna2CirclePictureBox1_Click(sender As Object, e As EventArgs) Handles img_back.Click
        a = a - 1
        If a = 0 Then
            img_back.Visible = False
        Else
            img_back.Visible = True
        End If

        If a < count - 1 Then
            img_next.Visible = True
        Else
            img_next.Visible = False
        End If
        GETMYID()
    End Sub

    Private Sub img_next_Click(sender As Object, e As EventArgs) Handles img_next.Click
        a = a + 1
        If a = count - 1 Then
            img_next.Visible = False
        Else
            img_next.Visible = True
        End If

        If a > 0 Then
            img_back.Visible = True
        Else
            img_back.Visible = False
        End If
        GETMYID()
    End Sub

    Private Sub btndesign_Click(sender As Object, e As EventArgs) Handles btndesign.Click
        With _Sales

            .txt_design.Text = txt_design.Text
            .txt_designprice.Text = txt_price.Text
            .lbl_id.Text = Guna2TextBox1.Text
        End With
        Me.Hide()
    End Sub

    Private Sub Guna2Panel1_Paint(sender As Object, e As PaintEventArgs) Handles Guna2Panel1.Paint

    End Sub
End Class
Posted
Comments
Richard MacCutchan 20-Dec-23 10:21am    
So I assume that somewhere in all that code you get an error message. Please use the Improve question link above, and add proper details of where the error occurs.
Andre Oosthuizen 20-Dec-23 16:42pm    
In this part of your code there is something or a value you are making a call to that does not exist -
Guna2TextBox1.Text = dt.Rows(a).Item("ID")
txt_design.Text = txt_design.PlaceholderText & ": " & dt.Rows(a).Item("Design")
_Sales.lbl_design.Text = dt.Rows(a).Item("Design")
check_head.Checked = dt.Rows(a).Item("Headstone")
txt_head.Text = txt_head.PlaceholderText & ": " & dt.Rows(a).Item("Headstone_size")
chc_ledger.Checked = dt.Rows(a).Item("Ledger")
txt_ledger.Text = txt_ledger.PlaceholderText & ": " & dt.Rows(a).Item("Ledger_size")
chc_strips.Checked = dt.Rows(a).Item("Strips")
txt_strips.Text = txt_strips.PlaceholderText & ": " & dt.Rows(a).Item("Strips_size")
chc_vases.Checked = dt.Rows(a).Item("Vases")
chc_pavers.Checked = dt.Rows(a).Item("Pavers")
chc_flower.Checked = dt.Rows(a).Item("Flower_boarderline")
chc_logo.Checked = dt.Rows(a).Item("Logo_emblem")
chc_pic.Checked = dt.Rows(a).Item("Picture")
cmb_picsize.Text = dt.Rows(a).Item("Picture_size")
txt_price.Text = txt_price.PlaceholderText & ": USD $" & dt.Rows(a).Item("Price")
_Sales.lbl_price.Text = dt.Rows(a).Item("Price")
txt_colour.Text = txt_colour.PlaceholderText & ": " & dt.Rows(a).Item("Colour")

Check each value and make sure it is exists else it will error...

1 solution

I would suspect that the error message you are getting is not "Parameter not found" but "Parameter is not valid", and that's a pretty common error for "image from DB" problems - it's actually caused by the code you used to insert the image to the DB, not the code to extract it.

Have a look here: Why do I get a "Parameter is not valid." exception when I read an image from my database?[^] - the code is in C#, but there are online converters like this which translate VB to C# and vice versa: Code Converter C# to VB and VB to C# – Telerik[^] is one example.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900