Imports System.IO
Imports System.Text
Imports System.Data.sqlClient
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles Button1.Click
Dim s As String = ""
Dim FileStr As New FileStream("F:/模拟自动更新安装部署.msi",FileMode.Open,FileAccess.Read) '文件位置
Dim TempBytes(FileStr.Length - 1) As Byte
Dim idd As Integer = FileStr.Read(TempBytes,FileStr.Length)
FileStr.Close()
Dim a As Integer = s.Length
Dim connStr As String = "server=192.168.0.127;database=测试sql;uid=sa;password="
Dim conn As sqlConnection = DBHelp.DBConn(connStr)
Dim ds As New DataSet()
Dim dp As New sqlDataAdapter("SELECT * FROM 版本表 WHERE 1=0",conn)
Dim aa As sqlCommandBuilder = New sqlCommandBuilder(dp)
dp.Fill(ds)
Dim DTR As DataRow = ds.Tables(0).NewRow()
DTR("版本号") = "1.0.0.1"
DTR("更新日期") = DateTime.Now.ToString()
DTR("更新文件") = TempBytes
ds.Tables(0).Rows.Add(DTR)
dp.Update(ds)
conn.Close()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles Button2.Click Dim connStr As String = "server=192.168.0.127;database=测试sql;uid=sa;password=" Dim conn As sqlConnection = DBHelp.DBConn(connStr) Dim ds As New DataSet() Dim dp As New sqlDataAdapter("SELECT * FROM 版本表",conn) Dim aa As sqlCommandBuilder = New sqlCommandBuilder(dp) dp.Fill(ds) Dim TempBytes() As Byte = ds.Tables(0).Rows(0)("更新文件") Dim FileStr As New FileStream("F:/模拟自动更新安装部署还原.msi",FileMode.Create,FileAccess.Write) FileStr.Write(TempBytes,TempBytes.Length) FileStr.Close() End SubEnd Class
原文链接:https://www.f2er.com/vb/261237.html