08-07-17, 11:43 AM
أخي لم أفهم قصدك .... هذا هو كود الحفظ ...
---------------------------------------
Try
ofd.Filter = "jpg|*.jpg|bmp|*.bmp|png|*.png"
If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then
'Path of Image
Dim imgpath As String = ofd.FileName
'Path Of Name
Dim imgname As String = System.IO.Path.GetFileName(imgpath)
Dim newpath As String = Application.StartupPath & "\Images\" & imgname
picImage.Load(imgpath)
picImage.SizeMode = PictureBoxSizeMode.StretchImage
'Copy the pic link from pathe to new path
My.Computer.FileSystem.CopyFile(imgpath, newpath)
'*******************
con.Open()
sqlstr = "Insert Into TB1(AutoId,Name1,Path1,Note1) Values(@AutoId,@Name1,@Path1,@Note1)"
cmd = New OleDbCommand(sqlstr, con)
cmd.Parameters.Add("@AutoId", OleDbType.VarWChar).Value = txtAutoId.Text
cmd.Parameters.Add("@Name1", OleDbType.VarWChar).Value = imgname
cmd.Parameters.Add("@Path1", OleDbType.VarWChar).Value = newpath
cmd.Parameters.Add("@Note1", OleDbType.VarWChar).Value = txtNote.Text
cmd.ExecuteNonQuery()
con.Close()
FillDGV()
con.Close()
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
-------------------------------------------------------------------
---------------------------------------
Try
ofd.Filter = "jpg|*.jpg|bmp|*.bmp|png|*.png"
If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then
'Path of Image
Dim imgpath As String = ofd.FileName
'Path Of Name
Dim imgname As String = System.IO.Path.GetFileName(imgpath)
Dim newpath As String = Application.StartupPath & "\Images\" & imgname
picImage.Load(imgpath)
picImage.SizeMode = PictureBoxSizeMode.StretchImage
'Copy the pic link from pathe to new path
My.Computer.FileSystem.CopyFile(imgpath, newpath)
'*******************
con.Open()
sqlstr = "Insert Into TB1(AutoId,Name1,Path1,Note1) Values(@AutoId,@Name1,@Path1,@Note1)"
cmd = New OleDbCommand(sqlstr, con)
cmd.Parameters.Add("@AutoId", OleDbType.VarWChar).Value = txtAutoId.Text
cmd.Parameters.Add("@Name1", OleDbType.VarWChar).Value = imgname
cmd.Parameters.Add("@Path1", OleDbType.VarWChar).Value = newpath
cmd.Parameters.Add("@Note1", OleDbType.VarWChar).Value = txtNote.Text
cmd.ExecuteNonQuery()
con.Close()
FillDGV()
con.Close()
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
-------------------------------------------------------------------
