我在VB.Net 2013工作。这是一个桌面应用程序。
我将Excel文档(.xlsx)存储在SQL Server数据库中作为二进制数据。我希望能够发送这个文件'擅长将其作为临时文件写出来。
这可能吗?
目前我通过编写如下文件来完成它,但我宁愿不必编写临时文件
Dim dtExcel As New DataTable
Dim oDaEx As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter("Select * from [tblTV4] Where oPath = '" & txtPath.Text & "'", oCon)
Try
oDaEx.Fill(dtExcel)
Dim oRow As DataRow = dtExcel.Rows(0)
Dim filename = System.IO.Path.GetTempPath & "\" & oRow!oFilename
Dim fs As New System.IO.FileStream(filename, IO.FileMode.Create)
Dim bw As New System.IO.BinaryWriter(fs)
bw.Write(oRow!Excel)
bw.Close()
fs.Close()
Process.Start(filename)
Catch ex As Exception
Debug.Print(ex.Message)
End Try