من این کد رو از سایت اصلی پیدا کردم ببینید درسته یا نه
با این عکس رو میزاری تو دیتابیس
Sub InsertBlob
'convert the image file to a bytes array
Dim InputStream1 As InputStream
InputStream1 = File.OpenInput(File.DirAssets, "smiley.gif")
Dim OutputStream1 As OutputStream
OutputStream1.InitializeToBytesArray(1000)
File.Copy2(InputStream1, OutputStream1)
Dim Buffer() As Byte
Buffer = OutputStream1.ToBytesArray
'write the image to the database
MyBank.ExecNonQuery2("INSERT INTO tbl1 VALUES('smiley', ?)", Array As Object(Buffer))
End Sub
و با این فراخوانی میکنی
Sub ReadBlob
Dim Cursor1 As Cursor
'Using ExecQuery2 is safer as it escapes special characters automatically.
'In this case it doesn't really matter.
Cursor1 = SQL1.ExecQuery2("SELECT image FROM table2 WHERE name = ?", Array As String("smiley"))
Cursor1.Position = 0
Dim Buffer() As Byte 'declare an empty byte array
Buffer = Cursor1.GetBlob("image")
Dim InputStream1 As InputStream
InputStream1.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
Dim Bitmap1 As Bitmap
Bitmap1.Initialize2(InputStream1)
InputStream1.Close
Activity.SetBackgroundImage(Bitmap1)
End Sub
سوال
majid08 266
سلام دوستان
من این کد رو از سایت اصلی پیدا کردم ببینید درسته یا نه
با این عکس رو میزاری تو دیتابیس
Sub InsertBlob 'convert the image file to a bytes array Dim InputStream1 As InputStream InputStream1 = File.OpenInput(File.DirAssets, "smiley.gif") Dim OutputStream1 As OutputStream OutputStream1.InitializeToBytesArray(1000) File.Copy2(InputStream1, OutputStream1) Dim Buffer() As Byte Buffer = OutputStream1.ToBytesArray 'write the image to the database MyBank.ExecNonQuery2("INSERT INTO tbl1 VALUES('smiley', ?)", Array As Object(Buffer)) End Subو با این فراخوانی میکنی
Sub ReadBlob Dim Cursor1 As Cursor 'Using ExecQuery2 is safer as it escapes special characters automatically. 'In this case it doesn't really matter. Cursor1 = SQL1.ExecQuery2("SELECT image FROM table2 WHERE name = ?", Array As String("smiley")) Cursor1.Position = 0 Dim Buffer() As Byte 'declare an empty byte array Buffer = Cursor1.GetBlob("image") Dim InputStream1 As InputStream InputStream1.InitializeFromBytesArray(Buffer, 0, Buffer.Length) Dim Bitmap1 As Bitmap Bitmap1.Initialize2(InputStream1) InputStream1.Close Activity.SetBackgroundImage(Bitmap1) End Subلینک ارسال
به اشتراک گذاری در سایت های دیگر
0 پاسخ به این سوال تاکنون داده شده است
ارسالهای توصیه شده
بایگانی شده
این موضوع بایگانی و قفل شده و دیگر امکان ارسال پاسخ نیست.