08-03-13, 06:46 PM
احاول احفظ صور متعددة الى قاعدة بيانات sql server بعد تحويلها الى binary لكن اتفاجا بظهور رسالة الخطا:
String or binary data would be truncated.
The statement has been terminated.
مع انه تم حفظ ثلاث صور فقط من المجلد ..الكود هو :
ارجو المساعدة لحل هذا الاشكال فقد بحثت بقوقل بالعربي والانجليزي وكل ما وجدته لم يحل.
String or binary data would be truncated.
The statement has been terminated.
مع انه تم حفظ ثلاث صور فقط من المجلد ..الكود هو :
كود :
For Each fl In IO.Directory.GetFiles(fbd.SelectedPath & "\")
If IO.Path.GetExtension(IO.Path.GetFileName(fl)) = ".jpg" = True Or IO.Path.GetExtension(IO.Path.GetFileName(fl)) = ".gif" Or IO.Path.GetExtension(IO.Path.GetFileName(fl)) = ".png" Or IO.Path.GetExtension(IO.Path.GetFileName(fl)) = ".jpeg" Or IO.Path.GetExtension(IO.Path.GetFileName(fl)) = ".JPG" Then
'MsgBox(IO.Path.GetExtension(IO.Path.GetFileName(fl)))
' MsgBox("jpg")
Dim p() As Byte = My.Computer.FileSystem.ReadAllBytes(IO.Path.GetFullPath(fl))
Dim cm As New SqlCommand("insert into pic (picname,picbyte) values (@picname,@picbyte)", con)
cm.Parameters.AddWithValue("@picname", SqlDbType.VarChar).Value = IO.Path.GetFileName(fl)
cm.Parameters.AddWithValue("@picbyte", p)
cm.ExecuteNonQuery()
ProgressBar1.Value += 1
ll.Text = ProgressBar1.Value
End If
Next