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
'///////////////coding

Dim sqlConn As New SqlClient.SqlConnection(ConnectionString)
        sqlConn.Open()
        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")
            TextBox1.Select()
            Exit Sub
        End If
        If Trim$(Name) = "" Then
            strMsg = "Please enter your NAME before saving the record."
            MsgBox(strMsg, vbInformation, "FingerPrintIdentification")
            TextBox2.Select()
            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)


      
        '///////////////////
        Try

            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

            datPubs.Tables("InkPaperData").Rows.Add(drNewRow)
        Catch ex As System.Data.SqlClient.SqlException
            MsgBox(ex.Message)
        End Try

        'Save Ink finger String Data to record


        'End Save Ink finger String Data to record
     
        Add_Data()
        'Save_Record = True
        Buttons_Caption(False)
        Exit Sub

Save_Record_Error:
        Err.Raise(Err.Number, Err.Source, Err.Description)
        Err.Clear()

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

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

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.

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.