26-10-24, 07:37 PM
الأخوة الأعزاء
السلام عليكم ورحمة الله وبركاته ،،،
عملت مشروع بالفيجوال بيسك وهو جاهز حالياً والصور بالمشروع تحفظ في قاعدة البيانات Access ولكن قاعدة البيانات محدودة بـ 2 قيقا فقط والصور راح تاخذ هذا الحجم بسرعة
فهل يمكن تغيير كود الحفظ في قاعدة البيانات إلى الحفظ في مجلد داخل مسار البرنامج
والكود الحالي هو
Module
كود الحفظ
كود التعديل
السلام عليكم ورحمة الله وبركاته ،،،
عملت مشروع بالفيجوال بيسك وهو جاهز حالياً والصور بالمشروع تحفظ في قاعدة البيانات Access ولكن قاعدة البيانات محدودة بـ 2 قيقا فقط والصور راح تاخذ هذا الحجم بسرعة
فهل يمكن تغيير كود الحفظ في قاعدة البيانات إلى الحفظ في مجلد داخل مسار البرنامج
والكود الحالي هو
Module
كود :
Public Sub ChoosePicture(Pbox As PictureBox)
Dim a As New OpenFileDialog
With a
.AddExtension = True
.CheckPathExists = True
.CheckFileExists = True
.Title = "Choose Image"
.Filter = "Choose Image (*.PNG; *.JPG; *.GIF; *.JPEG)| *.PNG; *.JPG; *.GIF; *.JPEG | All Files (*.*)|*.*"
If .ShowDialog = DialogResult.OK Then
Pbox.Image = Image.FromFile(.FileName)
End If
End With
End Sub
Public Function DGVCurrentImageView(ByVal byt As Byte()) As Image
Dim MS As New System.IO.MemoryStream()
Dim drwing As Image = Nothing
MS.Write(byt, 0, byt.Length)
drwing = New Bitmap(MS)
MS.Close()
Return drwing
End Functionكود الحفظ
كود :
Public Sub Insert_Car_Arshef(ByVal ID As Long, ByVal Car_Doc As PictureBox)
Dim Cmd As New OleDbCommand
With Cmd
.Connection = con
.CommandType = CommandType.Text
.CommandText = "Insert Into Car_Arshef ( ID,Car_Doc)values(@ID,@Car_Doc)"
.Parameters.Clear()
.Parameters.AddWithValue("@ID", OleDbType.Integer).Value = ID
Dim ms As New MemoryStream()
Dim bmpImage As New Bitmap(Car_Doc.Image)
bmpImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg)
Dim data As Byte() = ms.GetBuffer()
Dim p As New OleDbParameter("@Car_Doc", OleDbType.Binary)
p.Value = data
.Parameters.Add(p)
End With
If con.State = 1 Then con.Close()
con.Open()
Cmd.ExecuteNonQuery()
con.Close()
MsgBox("تم إضافة السجل بنجاح", MsgBoxStyle.Information, "حفظ")
Cmd = Nothing
End Subكود التعديل
كود :
Public Sub Update_Car_Arshef(ByVal Car_Doc As PictureBox, ByVal IDW As Long)
Dim Cmd As New OleDbCommand
With Cmd
.Connection = con
.CommandType = CommandType.Text
.CommandText = "Update Car_Arshef Set Car_Doc = @Car_Doc Where ID = @ID"
.Parameters.Clear()
Dim ms As New MemoryStream()
Dim bmpImage As New Bitmap(Car_Doc.Image)
bmpImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg)
Dim data As Byte() = ms.GetBuffer()
Dim p As New OleDbParameter("@Car_Doc", OleDbType.LongVarBinary)
p.Value = data
.Parameters.Add(p)
.Parameters.AddWithValue("@ID", OleDbType.Integer).Value = IDW
End With
If con.State = 1 Then con.Close()
con.Open()
Cmd.ExecuteNonQuery()
con.Close()
MsgBox("تم تعديل السجل بنجاح", MsgBoxStyle.Information, "تعديل")
Cmd = Nothing
End Sub
