تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
ما هو حل مشكلة هذا ال Error The connection was not closed. The connection's current
#1
كود :
Dim dt1 As New DataTable
       Dim cmd As New SqlCommand("select * from Products where ProductBarcode = '" + ProductBarcode.Text + "'", con)
       con.Open()
       Dim da As New SqlDataAdapter(cmd)
       da.Fill(dt1)
       If dt1.Rows.Count > 0 Then

           Dim A As Integer = Val(Qyt.Text)
           Dim cmdupdate As New SqlCommand

           With cmdupdate
               .Connection = con
               .CommandType = CommandType.Text
               .CommandText = "update Products set Qyt = Qyt + " & A & " where ProductBarcode = " & ProductBarcode.Text & ""

           End With
           Try
               If con.State = 1 Then con.Close()
               con.Open()
               cmdupdate.ExecuteNonQuery()
               con.Close()
               MsgBox("اسم المادة المدخلة موجود مسبقا - تم عملية التحديث بنجاح", MsgBoxStyle.Information, "تحديث كمية المادة")
               cmdupdate = Nothing
           Catch ex As Exception
               con.Close()
               MsgBox(Err.Description, MsgBoxStyle.Information)
           Finally
               If con.State = ConnectionState.Open Then con.Close()
           End Try
       Else
           insert_products(ProductID.Text, ProductName.Text, ProductBarcode.Text, CatID.Text, UnitID.Text, Qyt.Text, BuyPrice.Text, SellPrice.Text, ImporterID.Text)

       End If
       clearcontroal()
       ProductID.Text = getmaxid("Products", "ProductID")
الرد }}}
تم الشكر بواسطة:


الردود في هذا الموضوع
ما هو حل مشكلة هذا ال Error The connection was not closed. The connection's current - بواسطة mostafa nada - 12-02-19, 03:33 AM


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


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