回复 5楼loovvezhengyi的帖子
你好懒啊 哈哈
>>“另外我还想把这个XML存到数据库某一个字段下怎么实现啊”
以下代码 将 “me”换成 控件名即可。自己转成C#代码!!!!!!!
Dim ms As New MemoryStream()
Dim xlsbyteG(ms.Length) As Byte
'isXML 你自己判断
If isXML Then
Me.Save(ms, False)
Else
Me.SaveExcel(ms)
End If
xlsbyteG = ms.ToArray
fileByte = xlsbyteG
'其他判断
Dim fs = New FileStream(fromFilePath, IO.FileMode.Open, IO.FileAccess.Read)
Dim xlsbyteF(fs.Length - 1) As Byte
fs.Read(xlsbyteF, 0, fs.Length - 1)
fs.Close()
存数据库关键部分:
sql = "UPDATE " & tableName & " SET " & gridField & " = @" & gridField & " WHERE 1=1 AND " & conditions
Dim cmd As New SqlCommand(sql, thisConnection)
cmd.Parameters.AddWithValue("@" & gridField, DbType.Binary)
cmd.Parameters("@" & gridField).Value = fileByte
cmd.ExecuteNonQuery()
cmd.Dispose() |