Please help i wanted to use the update panel to stop the page from posting changes before i complete the transaction but it is flagging the error below please help.
System.NullReferenceException: 'Object reference not set to an instance of an object.'
System.Web.UI.WebControls.FileUpload.PostedFile.get returned Nothing.
Protected Sub Upload(sender As Object, e As EventArgs) Handles btnUpload.Click
Dim filename As String = Path.GetFileName(FileUpload1.PostedFile.FileName)
If filename = "" Then
updatedata2000()
Else
updatedata()
Dim contentType As String = FileUpload1.PostedFile.ContentType
Using fs As Stream = FileUpload1.PostedFile.InputStream
Using br As New BinaryReader(fs)
Dim bytes As Byte() = br.ReadBytes(DirectCast(fs.Length, Long))
Dim constr As String = ConfigurationManager.ConnectionStrings("INTERVIEWSConnectionString").ConnectionString
Using con As New SqlConnection(constr)
Dim query As String = "insert into tblFiles values (@Name, @ContentType, @Data,@admno,@Studentnames,@comments)"
Using cmd As New SqlCommand(query)
cmd.Connection = con
cmd.Parameters.Add("@Name", SqlDbType.VarChar).Value = filename
cmd.Parameters.Add("@ContentType", SqlDbType.VarChar).Value = contentType
cmd.Parameters.Add("@Data", SqlDbType.Binary).Value = bytes
cmd.Parameters.Add("@admno", SqlDbType.Binary).Value = admno.Text
cmd.Parameters.Add("@Studentnames", SqlDbType.Binary).Value = StudentNames.Text
cmd.Parameters.Add("@comments", SqlDbType.Binary).Value = commentsdatakt.Text
con.Open()
cmd.ExecuteNonQuery()
con.Close()
End Using
End Using
End Using
End Using
Response.Redirect(Request.Url.AbsoluteUri)
End If