存到sql2000中的exe重新读取后变无效的win32程序求助
请问下 exe程序 存到sql2000中后
再读出来 生成 exe 会变 无效的win32程序
是什么原因? 可以解决么?
为了做一个 自动更新exe的功能,因为在外网
用一下代码把exe存到数据库
'读取文件
Dim fs = New System.IO.FileStream(TextBox1.Text, IO.FileMode.Open, IO.FileAccess.Read)
Dim imgData(fs.Length - 1) As Byte
fs.Read(imgData, 0, fs.Length - 1)
fs.close()
Dim tempConnection As New SqlConnection
Dim tempAdapter As SqlDataAdapter
Dim tempDataset As New DataSet
'打开数据库连接,取出数据
tempConnection.ConnectionString = "Server=.;DataBase=hua_fx;Uid=sa;pwd=;"
tempConnection.Open()
tempAdapter = New SqlDataAdapter("SELECT * FROM T_hsxtsj where 目标文件='WindowsApplicationfx.exe'", tempConnection)
tempAdapter.Fill(tempDataset)
'更新数据
Dim cb As New SqlCommandBuilder(tempAdapter)
tempDataset = New DataSet
tempAdapter.Fill(tempDataset)
tempDataset.Tables(0).Rows(0).Item("文件") = imgData
tempDataset.Tables(0).Rows(0).Item("版本号") = Getcurversion(TextBox1.Text)
tempAdapter.Update(tempDataset)
tempConnection.Close()
用以下代码 读取
Dim tempConnection As New SqlConnection
Dim tempAdapter As SqlDataAdapter
Dim tempDataset As New DataSet
'打开数据库连接,取出数据
tempConnection.ConnectionString = "Server=.;DataBase=hua_fx;Uid=sa;pwd=;"
tempConnection.Open()
tempAdapter = New SqlDataAdapter("SELECT * FROM T_hsxtsj where 目标文件='WindowsApplicationfx.exe'", tempConnection)
tempAdapter.Fill(tempDataset)
tempConnection.Close()
If tempDataset.Tables(0).Rows.Count > 0 Then
'将文件保存到硬盘文件c:\2.jpg
Dim imgData() As Byte
imgData = tempDataset.Tables(0).Rows(0).Item("文件")
Dim fs As FileStream
fs = File.Create("d:\WindowsApplicationfx.exe", imgData.Length - 1)
fs.Write(imgData, 0, imgData.Length - 1)
fs.Close()
MsgBox("OK")
Else
MsgBox("NO")
End If