الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

كود اضافة صورة الى قاعدة البيانات والقراءة من القاعدة

بدأه عبدالعزيز حبيش في 26 فبراير 2008 · 1 رد · 766 مشاهدة · في Microsoft Visual Basic.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

sql server 2005هذا كود اضافة صورة الى قاعدة البيانات من نوع

: كود الاضافة

' Save image to byte array.

Dim imagedata() As Byte = image.ToByteArray(New Atalasoft.Imaging.Codec.JpegEncoder(75))

' Create the SQL statement to add the image data.

myConnection = New SqlConnection(CONNECTION_STRING)

Dim myCommand As SqlCommand = New SqlCommand

("INSERT INTO Atalasoft_Image_Database (Caption, ImageData) VALUES ('" + txtCaption.Text + "', @Image)", myConnection)

Dim myParameter As SqlParameter = New SqlParameter("@Image", SqlDbType.Image, imagedata.Length)

myParameter.Value = imagedata

myCommand.Parameters.Add(myParameter)

' Open the connection and execture the statement.

myConnection.Open()

myCommand.ExecuteNonQuery()

myConnection.Close()

وهذا كود القراءة من القاعدة

الكود :

' Establish connection and SELECT statement.

myConnection = New SqlConnection(CONNECTION_STRING)

Dim myCommand As SqlCommand = New SqlCommand

("SELECT ImageData FROM Atalasoft_Image_Database WHERE Caption = '" + txtCaption.Text + "'", myConnection)

myConnection.Open()

' Get the image from the database.

Dim imagedata() As Byte = CType(myCommand.ExecuteScalar(), Byte())

If (Not imagedata Is Nothing) Then

Dim image As AtalaImage = AtalaImage.FromByteArray(imagedata)

Return image

Else

MessageBox.Show("Image does not exist in database.")

Return Nothing

End If

myConnection.Close()

#2

[quo

على الرابط الاخر

تم تعديل هذه المشاركة بواسطة عبدالعزيز حبيش في 26 فبراير 2008 في 16:57

مواضيع مشابهة

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…