I m writting a project
i want to save finger print image in sqlserver

but io.filemode.open is error occured, how can i solve for this, help me

Dim sqlConn As New SqlClient.SqlConnection(ConnectionString)
        Dim sqlComm As New SqlClient.SqlCommand("SELECT * From InkPaperData", sqlConn)
        Dim SaveAdapter As SqlClient.SqlDataAdapter '(" Select * From InkPaperData", sqlconn)
        'SaveAdapter = New SqlClient.SqlDataAdapter("Select * From InkPaperData", sqlConn)
        'Dim myReader As SqlClient.SqlDataReader = sqlComm.ExecuteReader()

        Dim datPubs As DataSet = New DataSet()
        SaveAdapter.Fill(datPubs, "InkPaperData")

        Dim drNewRow As DataRow = datPubs.Tables("InkPaperData").NewRow
        'Manipulate the data locally using the DataSet
        'SaveAdapter.Update(datPubs, "InkPaperData")

        Dim Idno, Name, strMsg As String


        Dim DirImage1, DirImage2, DirImage3, DirImage4, DirImage5 As String
        Dim DirImage6, DirImage7, DirImage8, DirImage9, DirImage10 As String
        Dim DirImage11 As String
        'Prompt for data to insert
        Idno = Trim$(TextBox1.Text)
        Name = Trim$(TextBox2.Text)

        If Trim$(Idno) = "" Then
            strMsg = "Please enter your ID Number before saving the record."
            MsgBox(strMsg, vbInformation, "FingerPrintIdentification")
            Exit Sub
        End If
        If Trim$(Name) = "" Then
            strMsg = "Please enter your NAME before saving the record."
            MsgBox(strMsg, vbInformation, "FingerPrintIdentification")
            Exit Sub
        End If
        DirImage1 = Trim$(TxtPicDir1.Text)
        DirImage2 = Trim$(TxtPicDir2.Text)
        DirImage3 = Trim$(TxtPicDir3.Text)
        DirImage4 = Trim$(TxtPicDir4.Text)
        DirImage5 = Trim$(TxtPicDir5.Text)
        DirImage6 = Trim$(TxtPicDir6.Text)
        DirImage7 = Trim$(TxtPicDir7.Text)
        DirImage8 = Trim$(TxtPicDir8.Text)
        DirImage9 = Trim$(TxtPicDir9.Text)
        DirImage10 = Trim$(TxtPicDir10.Text)

        DirImage11 = Trim$(TxtPicDir11.Text)


            Dim fs1 As New IO.FileStream(Trim$(DirImage1), IO.FileMode.Open)
            Dim Data1() As Byte = New [Byte](fs1.Length) {}
            fs1.Read(Data1, 0, fs1.Length)

            drNewRow(3) = Data1

            '///////left pointer
            Dim fs2 As New IO.FileStream(Trim(DirImage2), IO.FileMode.Open)
            Dim Data2() As Byte = New [Byte](fs2.Length) {}
            fs2.Read(Data2, 0, fs2.Length)
            drNewRow(4) = Data2

            drNewRow(1) = Idno
            drNewRow(2) = Name

            drNewRow(13) = FingerimageData1
            drNewRow(14) = FingerimageData2
            drNewRow(15) = FingerimageData3
            drNewRow(16) = FingerimageData4
            drNewRow(17) = FingerimageData5
            drNewRow(18) = FingerimageData6
            drNewRow(19) = FingerimageData7
            drNewRow(20) = FingerimageData8
            drNewRow(21) = FingerimageData9
            drNewRow(22) = FingerimageData10

        Catch ex As System.Data.SqlClient.SqlException
        End Try

        'Save Ink finger String Data to record

        'End Save Ink finger String Data to record
        'Save_Record = True
        Exit Sub

        Err.Raise(Err.Number, Err.Source, Err.Description)

'///////////////end coding

how can i solve for this io.filemode.open error exception
help me

8 Years
Discussion Span
Last Post by dickersonka

Would it not be better to set the 'image' field in the database as an Image or VarBinary(max). Then to add an image to the database you could pass in the bytes of the new image file that you want to upload.

Thats the approach I used when I wanted to store documents/images in SQL Server


It really depends on the amount of images you will expect to have in your database, security and speed needed.

Of course more image mean more space. If speed is an issue, the database isn't optimized for files, the filesystem is.

If you need the images in the database, correct, store them as images in sql, byte arrays as code, and pull them out as byte arrays.

This article 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.