您好我正在创建一个使用vb.net上传和查看文件的程序。 截至目前我有错误说HasFile不是System.Web.UI.WebControls.Button的成员以及“FileName”和“SaveAs”..
这是我的代码:
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles FileUpload1.Click
cmd.CommandText = "select max(fid) from Filedb"
cmd.Connection = con
Dim chk As Object = cmd.ExecuteScalar()
If IsDBNull(chk) Then
f_id = 1
Else
cmd.CommandText = "select max(fid) from Filedb"
cmd.Connection = con
f_id = cmd.ExecuteScalar()
f_id += 1
End If
If FileUpload1.HasFile Then
cmd.CommandText = "insert into Filedb(fid,Name) values(" & f_id & ",'" & FileUpload1.FileName & "')"
cmd.Connection = con
cmd.ExecuteNonQuery()
con.Close()
FileUpload1.SaveAs(Server.MapPath(FileUpload1.FileName))
End If
Response.Redirect("../Default.aspx")
End Sub
任何帮助将不胜感激。谢谢。