Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Pls someone help me. I have stored the images with a working code but when i try to retrieve it, that error appears. My application is to make admissions and regarding that, i want to review data entered and make alterations where necessary. For now, i want only the correct code to display the picture. Hope someone quickly help me

What I have tried:

VB
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        connection = New SqlConnection("server=.\SQLEXPRESS; Database=NMTC Admissions Database; integrated security=true")
        connection.Open()
        If IsNumeric(Tbs.Text) = False Or Tbs.Text = "" Then
            MessageBox.Show("Enter a Correct Index Number")
            Tbs.Focus()
            Exit Sub
        End If
        Dim command As New SqlCommand("select [First Name],[other name(s)],Gender, [year of admission], [previous s.h.s], [wassce/ ssce grade],[course to offer],[hostel details],phone,[school fees paid],[email address], std_photo from  Tbl_Students5 where std_id = @id", connection)
        command.Parameters.Add("@id", SqlDbType.VarChar).Value = Tbs.Text

        Dim table As New DataTable()
        Dim adapter As New SqlDataAdapter(command)



        adapter.Fill(table)
        If table.Rows.Count() <= 0 Then
            MessageBox.Show("Sorry, That Index Number Does Not Exist")
            Tbs.Focus()
            Exit Sub
        End If

        TbFn.Text = table.Rows(0)(0).ToString()
        TbOn1.Text = table.Rows(0)(1).ToString
        Tbgen.Text = table.Rows(0)(2).ToString
        Tbdate.Text = table.Rows(0)(3).ToString
        TbPs.Text = table.Rows(0)(4).ToString
        TbG.Text = table.Rows(0)(5).ToString
        TbCo.Text = table.Rows(0)(6).ToString
        TbHd.Text = table.Rows(0)(7).ToString
        TbCn.Text = table.Rows(0)(8).ToString
        TbFp.Text = table.Rows(0)(9).ToString
        TbE.Text = table.Rows(0)(10).ToString


        CbF.Checked = False
        CbM.Checked = False

            connection.Close()
end sub
Posted
Updated 30-Jun-17 4:10am
v3
Comments
Patrice T 30-Jun-17 9:07am    
if you look carefully, you are also told the position of error.

1 solution

See 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 it's pretty obvious (and online converters exist if you really can't read it: Code Converter[^] )
 
Share this answer
 

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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