تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
سؤال فى الحذف
#1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If TextBox1.Text.Trim = "" Or TextBox2.Text.Trim = "" Then Exit Sub

        Button1.Enabled = False
        Using con As New OleDb.OleDbConnection(str)
            Using cm As New OleDb.OleDbCommand("", con)
                cm.CommandText = "insert into country (countryname) values(@countryname)"
                cm.Parameters.AddWithValue("@countryname", TextBox1.Text)
                If con.State = ConnectionState.Closed Then con.Open()
                cm.ExecuteNonQuery()

                cm.Parameters.Clear()
                'انتبه اجعل الاتصال مفتوح لتحصل على آخر رقم اي دي
                cm.CommandText = "select@@identity"
                Dim id As Integer
                If con.State = ConnectionState.Closed Then con.Open()
                id = cm.ExecuteScalar
                If con.State = ConnectionState.Open Then con.Close()
                cm.Parameters.Clear()
                If con.State = ConnectionState.Closed Then con.Open()

                For Each h As String In TextBox2.Text.Split(vbNewLine)
                    cm.Parameters.Clear()
                    cm.CommandText = "insert into city (countryid,cityname) values(@countryid,@cityname)"
                    cm.Parameters.AddWithValue("@countryid", id)
                    cm.Parameters.AddWithValue("@cityname", h)
                    cm.ExecuteNonQuery()
                Next
                If con.State = ConnectionState.Open Then con.Close()
            End Using
        End Using
        gd()
        Button1.Enabled = True
        MsgBox("تم حفظ الدولة ومدنها", MsgBoxStyle.Information, "")


ازاى اعمل كود حذف من كود الاضافة السابق
الرد }}}
تم الشكر بواسطة:


الردود في هذا الموضوع
سؤال فى الحذف - بواسطة احمد خطاب - 26-12-19, 12:20 AM
RE: سؤال فى الحذف - بواسطة اسامه الهرماوي - 26-12-19, 01:45 AM
RE: سؤال فى الحذف - بواسطة احمد خطاب - 26-12-19, 02:41 AM
RE: سؤال فى الحذف - بواسطة mmali127 - 26-12-19, 02:30 PM
RE: سؤال فى الحذف - بواسطة اسامه الهرماوي - 26-12-19, 03:11 AM


التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم