![]() |
|
ما الغلط في كود التعديل التالي - نسخة قابلة للطباعة +- منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب (http://vb4arb.com/vb) +-- قسم : قسم لغة الفيجوال بيسك VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=182) +--- قسم : قسم اسئلة VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=183) +--- الموضوع : ما الغلط في كود التعديل التالي (/showthread.php?tid=36697) |
ما الغلط في كود التعديل التالي - برحوت - 13-10-20 ما الغلط في كود التعديل التالي بحيث عند تعديل الاسم يعطينا رسالة ان هذا الاسم الاسم موجود من قبل رغم انة غير موجود باقي الحقول يعدلها ؟ ارجو المساعدة هذا الصاب Public Sub update_Federations_indirect() 'كود تعديل جدول الاقاليم Dim dt As New DataTable Dim da As New SqlDataAdapter dt.Clear() da = New SqlDataAdapter("Select * FROM Federations where (Federationid = " & Federations.FederationId.Text & ") and (FederationNameA = N'" & Federations.FederationNameA.Text & "')", con) da.Fill(dt) ' if Column present give msgbox to alert & Dont save If dt.Rows.Count = 0 Then MsgBox("هذا الإقليم موجود من قبل ", MsgBoxStyle.Critical, "بيانات غير مسجلة ") Else Dim pos As Integer = Federations.BindingContext(dt).Position dt.Rows(pos).Item("FederationNameA") = Federations.FederationNameA.Text dt.Rows(pos).Item("Federationphone") = Federations.FederationPhone.Text dt.Rows(pos).Item("FederationPhone1") = Federations.FederationPhone1.Text dt.Rows(pos).Item("FederationTell") = Federations.FederationTell.Text dt.Rows(pos).Item("Federationtelefax") = Federations.Federationtelefax.Text Dim Save As New SqlCommandBuilder(da) da.Update(dt) dt.AcceptChanges() 'give msgbox to sure save MsgBox("تم التعديل بنجاح ", MsgBoxStyle.Information, "تاكيد التعديل") ' load table to refresh data LoadAllTable_Federations_InDirect(Federations.dgv) End If End Sub وهذا الكود الموجود في زر التعديل Private Sub btn_update_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_update.Click If MsgBox(" هل تريد تعديل بيانات الإقليم ؟", MsgBoxStyle.OkCancel) = MsgBoxResult.Ok Then Try If FederationNameA.Text = Nothing Then MsgBox("يرجى تسجيل إسم صالح للإقليم ") End If cls.update_Federations_indirect() cls.clearcontrols_Federations() Catch ex As Exception End Try End If End Sub |