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

نسخة كاملة : الحذف من قاعدة البيانات بشرط معين
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
الصفحات : 1 2
اعذرني اخي asemshahem و تحملني فقط لوجه الله
كل مرة تخطرلي ببالي اشكالية .هل يمكن اضافة للكود بحيث الاسم يلي ممكن نحذفو من الجدول الاول نحذفو بالمرة من الجدول الثاني مادام ليست له اي قيمة بالجدول الثاني و بارك الله فيك و اسف بجد

كود :
       If MsgBox("هل انت متأكد من عملية حذف السجل : " & TextBox2.Text, MsgBoxStyle.YesNo + MsgBoxStyle.MsgBoxRight + MsgBoxStyle.MsgBoxRtlReading, "") = MsgBoxResult.Yes Then
           Using cmd As OleDbCommand = New OleDbCommand("Delete From Table1 where [Name1]='" & TextBox2.Text.Trim & "' and [Name1] in (Select Name2 From Table2 where Sum1=0 and Sum2=0) ", con)
               If con.State = ConnectionState.Closed Then con.Open()
               If (cmd.ExecuteNonQuery()) > 0 Then
                   MessageBox.Show("تمت عملية حذف البيانات بنجاح", "رسالة تأكيد", MessageBoxButtons.OK, MessageBoxIcon.Information)
               Else
                   MessageBox.Show("لا يمكن حذف هذ السجل لارتباطه بقيم السجل الثاني", "رسالة تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Information)
               End If
               Form1_Load(Nothing, Nothing)
           End Using
       End If
تفضل اخي الكريم : 

PHP كود :
   Private Sub Button1_Click(sender As ObjectAs EventArgsHandles Button1.Click
        If MsgBox
("هل انت متأكد من عملية حذف السجل : " TextBox2.TextMsgBoxStyle.YesNo MsgBoxStyle.MsgBoxRight MsgBoxStyle.MsgBoxRtlReading"") = MsgBoxResult.Yes Then
            Dim Na 
As String TextBox2.Text
            Dim cmd 
As New OleDbCommand(
 
           "Delete From Table1 where [Name]='" TextBox2.Text.Trim "' and [Name] in (Select MyName From Table2 where MyName='" TextBox2.Text.Trim "' and Sum1=0 and Sum2=0) "con)
 
           If con.State ConnectionState.Closed Then con.Open()
 
           If (cmd.ExecuteNonQuery()) > 0 Then
                cmd 
= New OleDbCommand("Delete From Table2 where MyName='" Na "' and Sum1=0 and Sum2=0"con)
 
               cmd.ExecuteNonQuery()
 
               MsgBox("تم الحذف"MsgBoxStyle.MsgBoxRight MsgBoxStyle.MsgBoxRtlReading"")
 
           Else
                MsgBox
("لم يتم الحذف"MsgBoxStyle.MsgBoxRight MsgBoxStyle.MsgBoxRtlReading"")
 
           End If
 
           Form1_Load(NothingNothing)
 
       End If
 
   End Sub 
تمام اخي asemshahen هو المطلوب بالضبط ربنا يكرمك دنيا و اخرة ان شاء الله.تم التقييم  .. بارك الله يا رب
الله يسلمك دعائك اهم من التقييم .
والحمد الله رب العالمين .
الصفحات : 1 2