Hi
I have below code to save pdf file in sql. but getting error "Cannot Bulk Load. The File "D:\xyz.pdf" does not exist."
Private Sub ButBouncePdfAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButBouncePdfAdd.Click
Try
If TxtRefNo.Text <> "" Then
OpenFileDialog1.InitialDirectory = "d:\"
OpenFileDialog1.Title = "Select PDF File"
OpenFileDialog1.Filter = "PDF Files|*.pdf"
If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim FileName As String = OpenFileDialog1.FileName.ToString
Call Connect()
Dim cmd As New SqlClient.SqlCommand
cmd.Connection = CnCommon
cmd.CommandText = "UPDATE PDC_CHQ_IN_HAND SET PDF = (SELECT * FROM OPENROWSET(BULK '" & FileName & "', SINGLE_BLOB) SOMEALIAS) WHERE RefNo = '" & TxtRefNo.Text & "'"
cmd.ExecuteNonQuery()
MessageBox.Show("Image has been saved", "Save", MessageBoxButtons.OK)
CnCommon.Close()
CnCommon.Dispose()
End If
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub