2012-01-17 14 views
0

我正在處理與從掃描儀捕獲的圖像保存在文件夾和數據庫中有關的項目。掃描進行確定,但是當我保存在磁盤上的圖像,並在數據庫中,我得到了以下錯誤103666 vb.net用於在掃描後將圖像保存在圖像文件夾和數據庫中

DATABASE --tablename路徑 - image列 - (FILE_NAME,varchar50,空=真)(圖片,爲nvarchar(最大),空=真)

我的代碼如下:

Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click 
    ''SCAN THE IMAGE AND SAVE TO PROJECT FOLDER AND IN DATABASE (AS BLOB) 
    If True Then 
     ' Scanner selected? 
     Dim device = TryCast(Devices.SelectedItem, Scanner) 
     If device Is Nothing Then 
      MessageBox.Show("Please select a device.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning) 
      Return 
     End If 

     ' Scan 
     Dim image = device.Scan() 

     'Save the image 

     'Dim path = "image/" 
     'If File.Exists(path) Then 
     ' File.Delete(path) 
     'End If 
     'image.SaveFile(TextBox1.Text, "image/") 
     'image.save() 


    End If 

End Sub 
+0

檢查路徑大小是否超過50個字符。 – Harsh

回答

1

你有幾個問題,你的表設計:

1)文件名,在50個字符,最有可能不夠長,特別是如果你包括路徑。

2)將圖像數據存儲在nvarchar中很可能會導致很多問題。使用varbinary會更好。 Here is a link來自微軟的一些信息。

+0

你的答案是好的,但我想知道如何使用按鈕單擊事件將圖像保存在圖像文件夾及其在數據庫中的路徑 – kunal

相關問題