I am looking to upload a PDF from my VB.Net program to SQL Server. I have the below code.
我希望从我的VB.Net程序上传PDF到SQL Server。我有以下代码。
the file I need to upload needs to go into the uDoc column and the file path (C:\example.pdf) is the string inDoc.
我需要上传的文件需要进入uDoc列,文件路径(C:\ example.pdf)是字符串inDoc。
any ideas on how to complete my code.
关于如何完成我的代码的任何想法。
Thanks Rob
谢谢Rob
Sub UploadInvoice()
Dim myConn As SqlConnection
Dim inAcc As String
Dim inType As String
Dim inDoc As String
inAcc = Form1.tb1Account.Text
inType = frmInv.cbType.Text
inDoc = frmInv.tbFile.Text
myConn = New SqlConnection(strConnection)
myConn.Open()
Dim mycmd As New SqlCommand
mycmd.CommandText = "INSERT INTO tblInvoice (UDate, AccNo, Type, UDoc) VALUES(GETDATE(),'" & inAcc & "','" & inType & "','" & inDoc & "')"
mycmd.Connection = myConn
mycmd.ExecuteNonQuery()
myConn.Close()
End Sub
1 个解决方案
#1
0
If this is an ASP.Net application, use the FileUpload control. It emits a file input field in the browser so you can select a file (or multiple if using .Net 4.5 and an HTML5 compliant browser). You won't be able to get the full file path, but that is generally irrelevant since a web application has no ability to read a client file system. Save the uploaded file to a location and store that location in the db.
如果这是ASP.Net应用程序,请使用FileUpload控件。它在浏览器中发出文件输入字段,因此您可以选择一个文件(如果使用.Net 4.5和HTML5兼容的浏览器,则可以选择多个文件)。您将无法获得完整的文件路径,但这通常无关紧要,因为Web应用程序无法读取客户端文件系统。将上载的文件保存到某个位置,并将该位置存储在数据库中。
#1
0
If this is an ASP.Net application, use the FileUpload control. It emits a file input field in the browser so you can select a file (or multiple if using .Net 4.5 and an HTML5 compliant browser). You won't be able to get the full file path, but that is generally irrelevant since a web application has no ability to read a client file system. Save the uploaded file to a location and store that location in the db.
如果这是ASP.Net应用程序,请使用FileUpload控件。它在浏览器中发出文件输入字段,因此您可以选择一个文件(如果使用.Net 4.5和HTML5兼容的浏览器,则可以选择多个文件)。您将无法获得完整的文件路径,但这通常无关紧要,因为Web应用程序无法读取客户端文件系统。将上载的文件保存到某个位置,并将该位置存储在数据库中。