使用html的上传<INPUT id="FileUp" runat="server" type="file"〉

解决方案 »

  1.   

    如果只是将文件的内容加到数据库的话可以
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim conn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database Password=;Data Source=c:\inetpub\wwwroot\tax\SwCx.mdb;Mode=ReadWrite|Share Deny None;Persist Security Info=False")
            Dim comm As New OleDb.OleDbCommand
            comm.Connection = conn
            txtNr.Text = Replace(txtNr.Text, "<br/>", vbCrLf)
            comm.CommandText = "insert into fg (dw,wh,bt,lr) values ('" & txtDw.Text & "','" & txtWh.Text & "','" & txtBt.Text & "','" & txtNr.Text & "')"
            conn.Open()
            comm.ExecuteNonQuery()
    Response.Write("<script>alert('文档添加完成')</script>")
    end sub
      

  2.   

    用<input type=file name=file1 id=loadfile>控件来上传用户的文件。
    再将文件添加到数据库:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim conn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database Password=;Data Source=c:\inetpub\wwwroot\tax\SwCx.mdb;Mode=ReadWrite|Share Deny None;Persist Security Info=False")
            Dim comm As New OleDb.OleDbCommand
            comm.Connection = conn
            txtNr.Text = Replace(txtNr.Text, "<br/>", vbCrLf)
            comm.CommandText = "insert into fg (dw,wh,bt,lr) values ('" & txtDw.Text & "','" & txtWh.Text & "','" & txtBt.Text & "','" & txtNr.Text & "')"
            conn.Open()
            comm.ExecuteNonQuery()
    Response.Write("<script>alert('文档添加完成')</script>")
    end sub