MCTS Programming

www.SarafMoghadam.Com

MCTS Programming

www.SarafMoghadam.Com

دریافت عکس از دیتا بیس

Imports System.Data.SqlClient


Dim mem As New MemoryStream

com.CommandText = "select pic from table1 where name='" & safefilename & "'"

con.Open()

com.Connection = con

Dim image1 As Byte() = com.ExecuteScalar

mem.Write(image1, 0, image1.Length)

PictureBox1.Image = Image.FromStream(mem)

con.Close()

درج عکس در دیتا بیس

Imports System.Data.SqlClient


Dim image() As Byte = File.ReadAllBytes(filename)

con = New SqlConnection("Data Source=.\;Initial Catalog=نام دیتا بیس;Integrated         Security=True;Pooling=False")

com = New SqlCommand("insert into table1 (name,pic) values (@name,@pic)", con)

con.Open()

com.Parameters.AddWithValue("@name", safefilename)

com.Parameters.AddWithValue("@pic", image)

com.ExecuteNonQuery()

con.Close()