03-08-15, 03:00 PM
مثال بسيط (الاجراءات المخزنة - اكسس 2010 + فيجوال بيسك 2015)
![[صورة مرفقة: p1.jpg]](https://i.postimg.cc/bdqZyMWk/p1.jpg)
![[صورة مرفقة: p2.jpg]](https://i.postimg.cc/jCvLLcY9/p2.jpg)
![[صورة مرفقة: p3.jpg]](https://i.postimg.cc/6843bN4J/p3.jpg)
![[صورة مرفقة: p4.jpg]](https://i.postimg.cc/wtKBSbDt/p4.jpg)
![[صورة مرفقة: p5.jpg]](https://i.postimg.cc/XZwv3cgs/p5.jpg)
![[صورة مرفقة: p6.jpg]](https://i.postimg.cc/mzBgrzXB/p6.jpg)
![[صورة مرفقة: p7.jpg]](https://i.postimg.cc/mzj21LJM/p7.jpg)
![[صورة مرفقة: p1.jpg]](https://i.postimg.cc/bdqZyMWk/p1.jpg)
![[صورة مرفقة: p2.jpg]](https://i.postimg.cc/jCvLLcY9/p2.jpg)
![[صورة مرفقة: p3.jpg]](https://i.postimg.cc/6843bN4J/p3.jpg)
![[صورة مرفقة: p4.jpg]](https://i.postimg.cc/wtKBSbDt/p4.jpg)
![[صورة مرفقة: p5.jpg]](https://i.postimg.cc/XZwv3cgs/p5.jpg)
![[صورة مرفقة: p6.jpg]](https://i.postimg.cc/mzBgrzXB/p6.jpg)
![[صورة مرفقة: p7.jpg]](https://i.postimg.cc/mzj21LJM/p7.jpg)
كود :
Imports System.Data.OleDb
Imports System.IO
Public Class Form1
Dim str As String = "provider=microsoft.ace.oledb.12.0;data source=db.accdb"
Dim con As New OleDbConnection(str)
Dim cm As New OleDbCommand("", con)
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
cm.Parameters.Clear()
cm = New OleDbCommand("", con)
cm.CommandText = "aselect"
cm.CommandType = CommandType.StoredProcedure
If con.State = ConnectionState.Closed Then
con.Open()
End If
Dim dr As OleDbDataReader = cm.ExecuteReader
If dr.Read Then
tid.Text = dr(0)
tn.Text = dr(1)
Dim b() As Byte = dr.Item(2)
Dim ms As New MemoryStream(b)
apic.Image = Image.FromStream(ms)
End If
dr.Close()
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
If tn.Text.Trim.ToLower = "" Then Exit Sub
If foundcount(tn.Text) < 1 Then
cm.Parameters.Clear()
cm = New OleDbCommand("", con)
cm.CommandText = "ainsert"
cm.Parameters.AddWithValue("@tn", tn.Text)
Dim ms As New MemoryStream
apic.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg)
Dim b() As Byte = ms.ToArray
cm.Parameters.AddWithValue("@pic", b)
cm.CommandType = CommandType.StoredProcedure
If con.State = ConnectionState.Closed Then con.Open()
cm.ExecuteNonQuery()
Else
MsgBox("الاسم محجوز")
End If
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim tname As String = InputBox("ادخل الاسم المراد البحث عنه")
If tname.ToString.Trim <> "" Then
tid.Clear()
tn.Clear()
apic.Image = Nothing
cm.Parameters.Clear()
cm = New OleDbCommand("", con)
cm.CommandText = "asearch"
cm.Parameters.AddWithValue("@tn", tname)
cm.CommandType = CommandType.StoredProcedure
If con.State = ConnectionState.Closed Then
con.Open()
End If
Dim dr As OleDbDataReader = cm.ExecuteReader
If dr.Read Then
tid.Text = dr(0)
tn.Text = dr(1)
Dim b() As Byte = dr(2)
Dim ms As New MemoryStream(b)
apic.Image = Image.FromStream(ms)
End If
dr.Close()
End If
End Sub
Private Function foundcount(ByVal t As String) As Integer
cm = New OleDbCommand("", con)
cm.CommandText = "foundcount"
cm.Parameters.AddWithValue("@tn", t)
cm.CommandType = CommandType.StoredProcedure
If con.State = ConnectionState.Closed Then
con.Open()
End If
Return cm.ExecuteScalar
End Function
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
cm = New OleDbCommand("", con)
cm.CommandText = "aupdate"
Dim ms As New MemoryStream
apic.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg)
Dim b() As Byte = ms.ToArray
cm.Parameters.AddWithValue("@pic", b)
cm.Parameters.AddWithValue("@tid", Val(tid.Text))
cm.CommandType = CommandType.StoredProcedure
If con.State = ConnectionState.Closed Then
con.Open()
End If
cm.ExecuteNonQuery()
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
cm = New OleDbCommand("", con)
cm.CommandText = "adelete"
cm.Parameters.AddWithValue("@tid", Val(tid.Text))
cm.CommandType = CommandType.StoredProcedure
If con.State = ConnectionState.Closed Then
con.Open()
End If
cm.ExecuteNonQuery()
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
Dim ofd As New OpenFileDialog
If ofd.ShowDialog = DialogResult.OK Then
tn.Text = IO.Path.GetFileNameWithoutExtension(ofd.FileName)
' apic.Image = Image.FromFile(ofd.FileName)
End If
End Sub
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
Dim ofd As New OpenFileDialog
If ofd.ShowDialog = DialogResult.OK Then
' tn.Text = IO.Path.GetFileNameWithoutExtension(ofd.FileName)
apic.Image = Image.FromFile(ofd.FileName)
End If
End Sub
End Class
![[صورة مرفقة: dc1cf21f24cdad1.png]](http://www.m5zn.com/newuploads/2015/08/03/png//dc1cf21f24cdad1.png)
![[صورة مرفقة: 84c1f41296e4e43.png]](http://www.m5zn.com/newuploads/2015/08/03/png//84c1f41296e4e43.png)
![[صورة مرفقة: m5zn_a174f027a999ea9.jpg]](http://www.m5zn.com/newuploads/2015/08/03/jpg//m5zn_a174f027a999ea9.jpg)
![[صورة مرفقة: m5zn_f8dca11f1bc430a.jpg]](http://www.m5zn.com/newuploads/2015/08/03/jpg//m5zn_f8dca11f1bc430a.jpg)
![[صورة مرفقة: m5zn_f33bc4964f4b8e5.jpg]](http://www.m5zn.com/newuploads/2015/08/03/jpg//m5zn_f33bc4964f4b8e5.jpg)