0
Answer

update using stringbuilder.append and doing operation

Sousa Pambo

Sousa Pambo

9y
397
1
Hello everybody, I need your help on this problem, see...
 
Public Sub updateRequisicaoItemBar(ByVal r_id As Integer, ByVal qt As Integer, ByVal price As Double) 
Dim sqlBuilder As New System.Text.StringBuilder()
With sqlBuilder
.Append("update tbl_Stock  set ")
.Append("qtyEnviar='" & CDbl(.Append("qtyEnviar").ToString) + qt - CDbl(.Append("qty").ToString) & "',")
.Append("qty='" & qt & "',")
.Append("PU='" & preco & "'")
.Append("valor='" & (.Append("qty").ToString * price) & "',")
.Append("sent='" & 0 & "'")
.Append(" where id='" & r_id & "'")
End With
Using cn As SqlConnection = New SqlConnection(getConnectionStringFinance())
Try
cn.Open()
Using cm As SqlCommand = New SqlCommand(sqlBuilder.ToString, cn)
cm.ExecuteNonQuery()
MessageBox.Show("Updated")
End Using
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Using
End Sub
 
 The red lines seem not doing in the right way, what the right way doing this. please help