?? form3.vb
字號:
Imports System.IO
Imports System.Data.OleDb
Public Class Form3
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim s As String = "下載數據" & ChrW(928) & ChrW(931)
Dim encoding As System.Text.Encoding = encoding.Unicode
Dim b As Byte() = encoding.GetBytes(s.ToCharArray) ',0, 1)
b = System.Text.Encoding.Unicode.GetBytes(s.ToCharArray)
Using conn As New Data.OleDb.OleDbConnection(connStr)
Dim com As New Data.OleDb.OleDbCommand("", conn)
Dim comtext As String
com.Parameters.Add("@bin", OleDb.OleDbType.VarBinary).Value = System.Text.Encoding.Unicode.GetBytes(s.ToCharArray)
'comtext = String.Format("UPDATE 下載數據 SET Status={0} , Length={1},threadcount={2},thread='{3}' WHERE MD5={4}", dtData.status, dtData.Length, dtData.downThreadAmount, dtData.thData, Me.MyTaskInfo.md5)
comtext = "INSERT INTO ttt (aaa) VALUES (@bin)"
com.CommandText = comtext
conn.Open()
'com.ExecuteNonQuery()
com.Dispose()
End Using
LoadIniData()
End Sub
Sub LoadIniData()
Dim b() As Byte = Nothing
Using conn As New Data.OleDb.OleDbConnection(connStr)
Dim com As New Data.OleDb.OleDbCommand("", conn)
com.CommandText = "SELECT * FROM ttt WHERE ID=17"
conn.Open()
Dim dr As OleDb.OleDbDataReader = com.ExecuteReader
While dr.Read()
b = CType(dr.Item("aaa"), Byte())
End While
End Using
'ShowArray(a)
Console.WriteLine(BinToStr(b) & " ************:::::::")
End Sub
Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdsave.Click
Dim str As New MemoryStream
'save the image to the stream in .Jpeg format
pic.Image.Save(str, Imaging.ImageFormat.Jpeg)
Dim buffer(CInt(str.Length - 1)) As Byte
str.Position = 0
str.Read(buffer, 0, CInt(str.Length))
'create a connection to the images database in the root folder or our machine
Dim con As New OleDbConnection(connStr)
'create a command object based on this command
Dim cmd As New OleDbCommand("UPDATE ttt SET aaa = @ProductImage ", con)
cmd.CommandType = CommandType.Text
Dim prmPic As New OleDbParameter 'done step by step here
With prmPic
.ParameterName = "@ProductImage" 'the name used in the query for the parameter
.OleDbType = OleDbType.Binary 'set the database type
.Value = buffer 'assign the contents of the buffer to the value of the parameter
End With
cmd.Parameters.Add(prmPic) 'add the parameter to the command
Try
'open the connection
con.Open()
'execute the command
cmd.ExecuteNonQuery()
'report success and clear the image to allow the user to select another image
MessageBox.Show("The Record was saved successfully.")
pic.Image = Nothing
Catch ex As Exception
MessageBox.Show("There was a problem saving the Record." & ControlChars.CrLf & ex.Message)
Finally
'close the connection and free the memory we were using
If con.State = ConnectionState.Open Then con.Close()
con.Dispose() : cmd.Dispose()
con = Nothing : cmd = Nothing : prmPic = Nothing
End Try
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim s As String = "QWERT下載數據" & ChrW(928) & ChrW(931)
Dim encoding As System.Text.Encoding = encoding.Unicode
Dim b As Byte() = encoding.GetBytes(s.ToCharArray)
b = System.Text.Encoding.Unicode.GetBytes(s.ToCharArray)
Using conn As New Data.OleDb.OleDbConnection(connStr)
Dim com As New Data.OleDb.OleDbCommand("", conn)
Dim comtext As String
com.Parameters.Add("@bin", OleDb.OleDbType.VarBinary).Value = System.Text.Encoding.Unicode.GetBytes(s.ToCharArray)
comtext = "UPDATE ttt SET aaa =@bin WHERE ID=17"
com.CommandText = comtext
conn.Open()
com.ExecuteNonQuery()
com.Dispose()
End Using
End Sub
End Class
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -