Image stored in sqlserver

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2008
Posts: 1
Reputation: VirusHeart is an unknown quantity at this point 
Solved Threads: 0
VirusHeart VirusHeart is offline Offline
Newbie Poster

Image stored in sqlserver

 
0
  #1
Sep 4th, 2008
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
  1. Dim sqlConn As New SqlClient.SqlConnection(ConnectionString)
  2. sqlConn.Open()
  3. Dim sqlComm As New SqlClient.SqlCommand("SELECT * From InkPaperData", sqlConn)
  4. Dim SaveAdapter As SqlClient.SqlDataAdapter '(" Select * From InkPaperData", sqlconn)
  5. 'SaveAdapter = New SqlClient.SqlDataAdapter("Select * From InkPaperData", sqlConn)
  6. 'Dim myReader As SqlClient.SqlDataReader = sqlComm.ExecuteReader()
  7.  
  8. Dim datPubs As DataSet = New DataSet()
  9. SaveAdapter.Fill(datPubs, "InkPaperData")
  10.  
  11. Dim drNewRow As DataRow = datPubs.Tables("InkPaperData").NewRow
  12. 'Manipulate the data locally using the DataSet
  13. 'SaveAdapter.Update(datPubs, "InkPaperData")
  14.  
  15.  
  16. Dim Idno, Name, strMsg As String
  17.  
  18.  
  19.  
  20.  
  21. Dim DirImage1, DirImage2, DirImage3, DirImage4, DirImage5 As String
  22. Dim DirImage6, DirImage7, DirImage8, DirImage9, DirImage10 As String
  23. Dim DirImage11 As String
  24.  
  25. 'Prompt for data to insert
  26. Idno = Trim$(TextBox1.Text)
  27. Name = Trim$(TextBox2.Text)
  28.  
  29.  
  30. If Trim$(Idno) = "" Then
  31. strMsg = "Please enter your ID Number before saving the record."
  32. MsgBox(strMsg, vbInformation, "FingerPrintIdentification")
  33. TextBox1.Select()
  34. Exit Sub
  35. End If
  36. If Trim$(Name) = "" Then
  37. strMsg = "Please enter your NAME before saving the record."
  38. MsgBox(strMsg, vbInformation, "FingerPrintIdentification")
  39. TextBox2.Select()
  40. Exit Sub
  41. End If
  42. DirImage1 = Trim$(TxtPicDir1.Text)
  43. DirImage2 = Trim$(TxtPicDir2.Text)
  44. DirImage3 = Trim$(TxtPicDir3.Text)
  45. DirImage4 = Trim$(TxtPicDir4.Text)
  46. DirImage5 = Trim$(TxtPicDir5.Text)
  47. DirImage6 = Trim$(TxtPicDir6.Text)
  48. DirImage7 = Trim$(TxtPicDir7.Text)
  49. DirImage8 = Trim$(TxtPicDir8.Text)
  50. DirImage9 = Trim$(TxtPicDir9.Text)
  51. DirImage10 = Trim$(TxtPicDir10.Text)
  52.  
  53. DirImage11 = Trim$(TxtPicDir11.Text)
  54.  
  55.  
  56.  
  57. '///////////////////
  58. Try
  59.  
  60. Dim fs1 As New IO.FileStream(Trim$(DirImage1), IO.FileMode.Open)
  61. Dim Data1() As Byte = New [Byte](fs1.Length) {}
  62. fs1.Read(Data1, 0, fs1.Length)
  63.  
  64. drNewRow(3) = Data1
  65.  
  66.  
  67.  
  68. '///////left pointer
  69. Dim fs2 As New IO.FileStream(Trim(DirImage2), IO.FileMode.Open)
  70. Dim Data2() As Byte = New [Byte](fs2.Length) {}
  71. fs2.Read(Data2, 0, fs2.Length)
  72. drNewRow(4) = Data2
  73.  
  74.  
  75. drNewRow(1) = Idno
  76. drNewRow(2) = Name
  77.  
  78. drNewRow(13) = FingerimageData1
  79. drNewRow(14) = FingerimageData2
  80. drNewRow(15) = FingerimageData3
  81. drNewRow(16) = FingerimageData4
  82. drNewRow(17) = FingerimageData5
  83. drNewRow(18) = FingerimageData6
  84. drNewRow(19) = FingerimageData7
  85. drNewRow(20) = FingerimageData8
  86. drNewRow(21) = FingerimageData9
  87. drNewRow(22) = FingerimageData10
  88.  
  89. datPubs.Tables("InkPaperData").Rows.Add(drNewRow)
  90. Catch ex As System.Data.SqlClient.SqlException
  91. MsgBox(ex.Message)
  92. End Try
  93.  
  94. 'Save Ink finger String Data to record
  95.  
  96.  
  97. 'End Save Ink finger String Data to record
  98.  
  99. Add_Data()
  100. 'Save_Record = True
  101. Buttons_Caption(False)
  102. Exit Sub
  103.  
  104. Save_Record_Error:
  105. Err.Raise(Err.Number, Err.Source, Err.Description)
  106. Err.Clear()
  107.  
  108. '///////////////end coding

how can i solve for this io.filemode.open error exception
help me
Last edited by cscgal; Sep 4th, 2008 at 3:42 am. Reason: Added code tags
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 83
Reputation: Elmo_loves_you is an unknown quantity at this point 
Solved Threads: 0
Elmo_loves_you's Avatar
Elmo_loves_you Elmo_loves_you is offline Offline
Junior Poster in Training

Re: Image stored in sqlserver

 
0
  #2
Sep 8th, 2008
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
Michelle (Junior Developer)
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,162
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 138
dickersonka dickersonka is offline Offline
Veteran Poster

Re: Image stored in sqlserver

 
0
  #3
Sep 8th, 2008
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.
Custom Application & Software Development
www.houseshark.net
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the VB.NET Forum
Thread Tools Search this Thread



Tag cloud for VB.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC