I'm trying to get a button to upload an image to a database via a SQL connection. But I get the following:
"An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll
Additional information: Empty path name is not legal."
And the line in bold in this code is highlighted as the problem:
Private Sub Upload_Button_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Upload_Button.Click
Dim SQLreturn As Integer
Dim fsimage As System.IO.FileStream = New System.IO.FileStream(File_TextBox.Text, System.IO.FileMode.Open, System.IO.FileAccess.Read)Dim Picture(fsimage.Length) As Byte
fsimage.Read(Picture, 0, fsimage.Length)
Try
SqlConnection1.Open()
SqlCommand1.Parameters("@pictureTitle").Value = File_TextBox.Text
SqlCommand1.Parameters("@pictureDescription").Value = DescriptionBox.Text
SqlCommand1.Parameters("@pictureOwner").Value = System.Environment.UserName
SqlCommand1.Parameters("@pictureData").Value = Picture
SQLreturn = SqlCommand1.ExecuteNonQuery() 'command
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
SqlConnection1.Close()
End Try
If SQLreturn <> 1 Then
MessageBox.Show("Could not execute the INSERT query")
'results
Else
MessageBox.Show("INSERT completed successfully")
End If
File_TextBox.Clear()
End Sub
Any suggestions welcomed.
N.B. Also posted in Syntax forums by mistake, did not know how 2 delete from there.