08-12-16, 09:07 PM
طبعا لا يوجد في الكود امر تعديل على قاعدة البيانات
هذا االكود بعد التعديل يقوم بتعديل الكمية المخزنة في المتغير x
هذا االكود بعد التعديل يقوم بتعديل الكمية المخزنة في المتغير x
كود :
Dim x As Integer = 0
If Trim(TextBox1.Text) <> "" Then
Dim Str As String = "Select * from medicines where name1 ='" & Trim(ComboBox1.Text) & "'"
'Dim Str As String = "select * from altalabia_mostalama where no1 = " + TextBox1.Text + " "
Dim cmd As New SqlCommand(Str, con)
If con.State = ConnectionState.Closed Then con.Open()
Dim DrView As SqlDataReader = cmd.ExecuteReader
If DrView.Read Then
If Not IsDBNull(DrView.Item("quantity")) Then x = DrView("quantity")
x = x + Val(TextBox2.Text)
DrView.Close()
Dim myCommand = New SqlCommand
myCommand.CommandText = "UPDATE medicines SET quantity='" & x & "' WHERE name1 ='" & Trim(ComboBox1.Text) & "'"
myCommand.Connection = con
myCommand.ExecuteNonQuery()
Else
DrView.Close()
End If
End If
