1、方案1:
Dim img As Image = GetImage("H:\桌面\网络PNG图标\AMR000003.png")
Dim cmd As new SQLCommand
cmd.C
cmd.CommandText = "Insert Into EvdDoc (DtNam, DocFld,FlTm,EvdDoc) Values(?,?,?,?)"
cmd.Parameters.Add("@DtNam","CeShi1")
cmd.Parameters.Add("@DocFld","Nun")
cmd.Parameters.Add("@FlTm",Date.Now)
cmd.Parameters.Add("@EvdDoc",img )
cmd.ExecuteNonQuery
2、方案2
Dim fs As New IO.FileStream("H:\桌面\网络PNG图标\AMR000003.png", IO.FileMode.Open , IO.FileAccess.Read) '用文件流打开图片
Dim br As New IO.BinaryReader(fs) '根据文件流,申明一个二进制阅读器
Dim ImageByte() As Byte = br.ReadBytes(fs.Length) '阅读器读取文件流,并将读到的二进制放入数组ImageByte中,
Dim ImageString As String = BitConverter.ToString(imageByte).Replace("-", "")
Dim cmd As new SQLCommand
cmd.C
cmd.CommandText = "Insert Into EvdDoc (DtNam, DocFld,FlTm,EvdDoc) Values(?,?,?,?)"
cmd.Parameters.Add("@DtNam","CeShi1")
cmd.Parameters.Add("@DocFld","Nun")
cmd.Parameters.Add("@FlTm",Date.Now)
cmd.Parameters.Add("@EvdDoc","Ox" + ImageString )
cmd.ExecuteNonQuery