Hello,
I have been successfully inserting images from a SQL database into Word documents for quite some time.
A new requirement has arisen where we now want to put signature images in the documents when they have been uploaded into the database. This also works but I have a problem when no signature file has been loaded into database.
What I would like to do here is insert a standard ‘blank’ image from a file rather than database. Below is the code I am currently using. Is what I am trying to do possible and if so - how?
Thanks in advance.
Joe
Public Function GetSignatureImage(ByVal CoachID As Integer) As Byte()
Dim strBrandImage As Byte()
Using myConnection As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)
Const SQL As String = "Select SignImage from DB WHERE ID = @ID"
Dim myCommand As New SqlCommand(SQL, myConnection)
myCommand.Parameters.AddWithValue("@ID", ID)
myConnection.Open()
Dim myReader As SqlDataReader = myCommand.ExecuteReader
If myReader.Read Then
If (myReader("SignImage")) Is System.DBNull.Value Then
strBrandImage = Nothing
Else
strBrandImage = (myReader("SignImage"))
End If
End If
If strBrandImage Is Nothing Then
'Get image from a file and convert to byte - this is my problem
End If
myReader.Close()
myConnection.Close()
End Using
Return strBrandImage
End Function