hwkong1688
New member
- Joined
- Sep 16, 2011
- Messages
- 3
- Programming Experience
- Beginner
Hi,
I am new in VB 2008, why this code the number i add not expected what i want??
anyone help appreciated.
pls advised.


I am new in VB 2008, why this code the number i add not expected what i want??
anyone help appreciated.
pls advised.
VB.NET:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim com As New OleDbCommand
Dim d As Integer
Dim qty1 As Integer
Dim result
com.Connection = con2
com.CommandText = "Select count(Itemcode) from da where Itemcode ='" & TextBox1.Text & "'"
result = CInt(com.ExecuteScalar)
qty1 = ds2.Tables(0).Rows(d).Item("Qty") + Val(TextBox3.Text)
If result > 0 Then
com.CommandText = "Update da set Description ='" & TextBox2.Text & "',Qty=" & qty1 & " Where Itemcode ='" & TextBox1.Text & "'"
com.ExecuteNonQuery()
MsgBox("Record Updated")
Else
com.CommandText = "Insert into da(Itemcode,Description,Qty) values (@Itemcode, @Description, @Qty)"
With com.Parameters
.AddWithValue("@Itemcode", TextBox1.Text)
.AddWithValue("@Description", TextBox2.Text)
.AddWithValue("@Qty", TextBox3.Text)
End With
com.ExecuteNonQuery()
MsgBox("Record Inserted")
End If
End Sub