HI ,
I'm currently creating a system for medical record for our school project
i was wondering , if someone could help me.. i always get this error " Couldn't find 'C:/User/...' " i coudnt retrieve the filename of the picture so that i can store it in my database , BUT when I try my back up file it works .it save image in the Database
It's the same code , i did not change anything

here is a part my code.. please help :(

Private Sub MDISaveToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripButton.Click

        If Not didPreviouslyConnect Then
            MsgBox("Connecting to database")
        End If
        Dim isConnecting As Boolean = True
        While isConnecting

            oFullname = RegistrationForm.FirstNameTxt.Text & " " & RegistrationForm.MiddleInitialTxt.Text & " " & RegistrationForm.LastNameTxt.Text
            oBirthday = RegistrationForm.MonthCBtxt.Text & RegistrationForm.DayCBtxt.Text & RegistrationForm.YearCBtxt.Text


            Dim arrImage() As Byte
            arrImage = System.IO.File.ReadAllBytes(RegistrationForm.OpenFileDialog1.FileName)

            Try

                Dim cmd As New SqlCommand("Insert into Patient_TB(Patient_ID, PatientName,PatientAddress,ContactNumber,Height,Weight,Gender,Bloodtype,Birthday,PatientPicture) " & _
             " values( '" & RegistrationForm.PatientNoText.Text & "', '" & oFullname & "','" & RegistrationForm.AddressText.Text & "', '" & Trim(RegistrationForm.ContactNoTxt.Text) & "', '" & RegistrationForm.HeightTxtBox.Text & "', '" & RegistrationForm.WeightTxtbox.Text & "', '" + RegistrationForm.GenderCBtxt.SelectedItem + "', '" & RegistrationForm.BTypeTxt.Text & "','" & oBirthday & "',@PatientPicture)", dataconnect)

                cmd.Parameters.Add(New SqlParameter("@PatientPicture", _
                            SqlDbType.Image, arrImage.Length)).Value = arrImage
                dataconnect.Open()
                cmd.ExecuteNonQuery()
                dataconnect.Close()


                isConnecting = False
                didPreviouslyConnect = True

                MessageBox.Show("Saved to the database", "System Message", MessageBoxButtons.OK, MessageBoxIcon.Information)

            Catch



            End Try



        End While

thanks best of luck :)

Dim arrImage() As Byte
        Dim openFile As New OpenFileDialog
        If openFile.ShowDialog() = Windows.Forms.DialogResult.OK Then
            arrImage = System.IO.File.ReadAllBytes(openFile.FileName)
        Else
            Exit Sub
        End If

Thanks sir, i already figure it out .. thanks for your answer..

Then please mark this thread as solved

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.