join two table column values productstock (1st table) + Quantity (2nd table) but when stock is 0 create a problem

  • Thread starter Thread starter muhammadanzar
  • Start date Start date
M

muhammadanzar

Guest
hi,

i have two table

1st table have productStock column

2nd table Quantity column.

Now i want Quantity Increase, it add in Productstock + Quantity. At the start when productstock =0 i face the problem show in pictur1575314.png

Your can see my code

Private Sub showstock1()
Dim str As String
str = "'" + TextBox5.Text + "'"
Using connection As New SqlConnection("Data Source=.\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True")
' Using adapter As New SqlDataAdapter("SELECT Stock FROM ProductRegistration where ProductId =" & TextBox4.Text, connection)
Using adapter As New SqlDataAdapter("SELECT dbo.ProductRegistration.Stock, dbo.Pur_OrderDetail.Quantity FROM dbo.ProductRegistration INNER JOIN dbo.Pur_OrderDetail ON dbo.ProductRegistration.ProductId = dbo.Pur_OrderDetail.ProductId INNER JOIN dbo.Pur_Order ON dbo.Pur_OrderDetail.pur_orderId = dbo.Pur_Order.Pur_OrderId where dbo.ProductRegistration.ProductName =" & str, connection)
Using table As New DataTable()
adapter.Fill(table)
Try
If (table.Rows(0)("dbo.ProductRegistration.Stock") IsNot System.DBNull.Value) Then 'If dt.Rows(0)("sex") IsNot System.DBNull.Value
' If IsDBNull() Then
TextBox17.Text = table(0)(0) + table(0)(1)
Label8.Text = "Pack In Stock"


End If

Catch ex As Exception
' MessageBox.Show("Sorry Stock Finished", "Read Carefully", MessageBoxButtons.OKCancel, MessageBoxIcon.Hand)
Finally
End Try
End Using
End Using
End Using
End Sub




MUHAMMAD ANZAR E-mail : muhammadanzar@hotmail.com Mobile # :0092-3215096959

Continue reading...
 
Back
Top