منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب

نسخة كاملة : عايز كو للحذف
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
السلام عليك ممكن
كود للحذف من الاكسس
السّلام عليكم و رحمة الله و بركاته
توجد العديد من الطرق و هذه إحداها أخي الكريم ..
كود :
   Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
       Using Commandcheck As New OleDbCommand("SELECT MAX(ID) FROM FONCTIONNAIRE", Con)
           If Con.State = ConnectionState.Closed Then Con.Open()
           If Commandcheck.ExecuteScalar Is DBNull.Value Then
               MsgBox("قاعدة البيانات فارغة .. لا توجد بيانات لتنفيذ الأمر ")
               Con.Close()
               Exit Sub
           End If
       End Using
       If MsgBox("  هل أنت متأكّد من أنك تريد حذف بيانات هذا الموظّف :  " & TxtEmpName.Text & " ؟ ", MsgBoxStyle.YesNo + MsgBoxStyle.Critical, "تحذير") = MsgBoxResult.No Then
           Exit Sub
       ElseIf TextBox1.Text = "" Then
           MsgBox("الرجاء كتابة الرقم التسلسلي", MsgBoxStyle.MsgBoxRtlReading, "تنبيه")
       Else
           Using Command As New OleDbCommand("DELETE FROM FONCTIONNAIRE WHERE ID = @ID", Con)
               Command.Parameters.Add("@ID", OleDbType.Numeric).Value = TextBox1.Text
               If Con.State = ConnectionState.Closed Then Con.Open()
               If Command.ExecuteNonQuery() = 1 Then
                   MsgBox("تمت عملية الحذف بنجاح", MsgBoxStyle.MsgBoxRtlReading, "تنفيذ اجراء الحذف")
             Else
                   MsgBox("لم تتم عملية الحذف بنجاح", MsgBoxStyle.MsgBoxRtlReading, "تنفيذ اجراء الحذف")
                   Call SetState("View")
               End If
               Con.Close()
           End Using
       End If
   End Sub

تحياتي
(25-11-18, 08:27 PM)عبد العزيز البسكري كتب : [ -> ]
السّلام عليكم و رحمة الله و بركاته
توجد العديد من الطرق و هذه إحداها أخي الكريم ..
كود :
   Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
       Using Commandcheck As New OleDbCommand("SELECT MAX(ID) FROM FONCTIONNAIRE", Con)
           If Con.State = ConnectionState.Closed Then Con.Open()
           If Commandcheck.ExecuteScalar Is DBNull.Value Then
               MsgBox("قاعدة البيانات فارغة .. لا توجد بيانات لتنفيذ الأمر ")
               Con.Close()
               Exit Sub
           End If
       End Using
       If MsgBox("  هل أنت متأكّد من أنك تريد حذف بيانات هذا الموظّف :  " & TxtEmpName.Text & " ؟ ", MsgBoxStyle.YesNo + MsgBoxStyle.Critical, "تحذير") = MsgBoxResult.No Then
           Exit Sub
       ElseIf TextBox1.Text = "" Then
           MsgBox("الرجاء كتابة الرقم التسلسلي", MsgBoxStyle.MsgBoxRtlReading, "تنبيه")
       Else
           Using Command As New OleDbCommand("DELETE FROM FONCTIONNAIRE WHERE ID = @ID", Con)
               Command.Parameters.Add("@ID", OleDbType.Numeric).Value = TextBox1.Text
               If Con.State = ConnectionState.Closed Then Con.Open()
               If Command.ExecuteNonQuery() = 1 Then
                   MsgBox("تمت عملية الحذف بنجاح", MsgBoxStyle.MsgBoxRtlReading, "تنفيذ اجراء الحذف")
             Else
                   MsgBox("لم تتم عملية الحذف بنجاح", MsgBoxStyle.MsgBoxRtlReading, "تنفيذ اجراء الحذف")
                   Call SetState("View")
               End If
               Con.Close()
           End Using
       End If
   End Sub

تحياتي

شكرا جدا اخي العزيز