تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
مساعده لو سمحتوا فى تعديل كود اتصال INSERT
#1
المشكله انه دلواتى بيدرج من فاتورة مشتريات فاول شرط لو الرقم نفسه والسعر نفسه يعمل ابديت
والا دى بقى الى فيها مشكله عايزه يجيب اسم الصنف ويزود جمبع واحد
الكود الاول ده سليم وجربته الحمد لله 
كود :
cmd.CommandText = String.Format(" UPDATE [tab_pro] SET [qty] = qty +{0} , [price] = {2} WHERE [id] = {1} and  [price] = {2}   ", txt, ad, txP)
           If cmd.ExecuteNonQuery() Then

بس الى بعده بقى مش عارف الكود خالص 
كود :
     For Each r As DataGridViewRow In dgvprodac.Rows
           Dim ad As Integer = Val(r.Cells(0).Value)
           Dim txP As String = Val(r.Cells(1).Value)
           Dim txt As Integer = Val(r.Cells(2).Value)
           Dim txC As Integer = Val(r.Cells(3).Value)
           Dim STTR As String

           cmd.CommandText = String.Format(" UPDATE [tab_pro] SET [qty] = qty +{0} , [price] = {2} WHERE [id] = {1} and  [price] = {2}   ", txt, ad, txP)
           If cmd.ExecuteNonQuery() Then
               STTR = ("insert into tab_pro (label,qty,price,id) values ({0},{1},{2},{3+1})", txP, txt, txC , ad )
               cmd.ExecuteNonQuery()
           End If
       Next

{3+1} دى بجتهد انه ياخد اسم الصنف ويزود جمبه واحد
ارجو المساعده وشكرا لمجهودكم
واسم الصنف ممكن يجى كده
كود :
  If cmd.ExecuteNonQuery() Then
               Dim txC As Integer = ("select label from [tab_pro] WHERE [id] = {1} ", txt)
               STTR = ("insert into tab_pro (label,qty,price,id) values ({0},{1},{2},{3+1})", txP, txt, txC , ad )

               'cmd.CommandText = String.Format("insert into tab_pro SET [qty] = qty +{0} , [price] = {2} WHERE [id] = {1}   ", txt, ad)
               cmd.ExecuteNonQuery()
           End If
الرد }}}
تم الشكر بواسطة:



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


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