PDA

View Full Version : مقدار دهی به فیلدی از نوع Image



MShirzadi
شنبه 05 اسفند 1385, 10:55 صبح
با سلام خدمت دوستان

من می خوام یک فیلد از DataBase من که SQLServer است را Image بگزارم اما نمی توانم به آن مقدار دهی کنم میشه یک Sample برای این کار بزارین تا من مقدار دهی به این فیلد رو یاد بگیرم

با تشکر

Alireza_Salehi
شنبه 05 اسفند 1385, 13:40 عصر
باید فایل عکس رو از دیسک بخون و توی آرایه بایت بریزی بعد میتونی به این فیلد نسبت بدی!

ای سوال خیلی پرسیده شده یه کم جستجو کن!

mah.yar
شنبه 05 اسفند 1385, 17:06 عصر
ببین لینک زیر کمکت میکنه:
http://barnamenevis.org/forum/showthread.php?t=60966&highlight=%D0%CE%26%231740%3B%D1%E5+%DA%98%D3

saeed_rezaei
یک شنبه 06 اسفند 1385, 09:58 صبح
Dimms AsNewMemoryStream()
PictureBox1.Image.Save(ms, PictureBox1.Image.RawFormat)
DimarrImage() AsByte = ms.GetBuffer
ms.Close()
DimfrmStatusMessage AsNewfrmStatus()

IfNotdidPreviouslyConnect Then
frmStatusMessage.Show("Connecting to SQL Server")
EndIf

DimisConnecting AsBoolean = True
WhileisConnecting
Try
DimnorthwindConnection AsNewSqlConnection(connectionString)
DimstrSQL AsString = _
"INSERT INTO Picture (Filename, Picture)" & _
"VALUES (@Filename, @Picture)"
Dimcmd AsNewSqlCommand(strSQL, northwindConnection)
Withcmd
.Parameters.Add(NewSqlParameter("@Filename", _
SqlDbType.NVarChar, 50)).Value = arrFilename(0)
.Parameters.Add(NewSqlParameter("@Picture", _
SqlDbType.Image)).Value = arrImage
EndWith
northwindConnection.Open()
cmd.ExecuteNonQuery()
northwindConnection.Close()