Reputation: 71
`Dim con1 As New ADODB.Connection
Dim rs1 As New ADODB.Recordset
Dim sql1 As String
sql1 = "Update Balance set Balance_Amt = (Balance_Amt + " & a & ") where Company = " & Combo3.Text
con1.Execute (sql1)
"Can anyone say why this code does not work? It says No value for one or more required parameters"
Upvotes: 0
Views: 136
Reputation: 100748
I would guess that the immediate problem is that the SQL fragment
where Company = value
is invalid SQL. It should be quoted:
where Company = 'value'
But you really should be using SQL parameters.
e.g.
Using cmd = new SqlCommand("UPDATE Balance SET Balance_Amt = (Balance_Amt + @a) WHERE Company=@company", con1)
cmd.Parameters.AddWithValue("@a", a)
cmd.Parameters.AddWithValue("@company", company)
cmd.ExecuteNonQuery()
End Using
Upvotes: 1
Reputation: 7322
Print out the sql statement and see if it is ok, copy/paste it to the sql management studio. I think you are missing apostrophes around the string Combo3.Text.
Also consider what sql it would result in if Combo3.Text contains
'a'; delete from Balance
Upvotes: 0