Hello everyone,
I have a problem in my problem. I want to save file upload with or without file attachment in my database using the code below but get error like the system has been terminatted and truncated.
Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSubmit.Click
Dim filename As String = Path.GetFileName(FileUpload1.PostedFile.FileName)
FileUpload1.SaveAs(Server.MapPath("Files/" & filename))
Using con = OpenCon()
Dim cmd As New SqlCommand
cmd.Connection = con
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "INSERT_APPLICATION"
With cmd.Parameters
.Clear()
cmd.CommandType = CommandType.StoredProcedure
.AddWithValue("@Service", cboServices.Text.Trim())
.AddWithValue("@NameOfClient", txtName.Text.Trim())
.AddWithValue("@FileName", filename)
.AddWithValue("@FilePath", "Files/" & filename)
.AddWithValue("@DateAdded", DateTime.Now.ToString)
End With
cmd.ExecuteNonQuery()
End Using
End Sub