G
Guest
I have a vb.net app that is building a SQL statement. When the SQL statement
executes, it does not error, but updates zero rows. If I take the statement
and paste it into my Access database as a Query and execute it, it updates
rows. My code is moving data from one column to another in the same table.
Dim cnSQL As New OleDbConnection
Dim cmd As New OleDbCommand
Dim sSQL As String
Dim iCount As Integer
Dim X As Integer
Dim sPayer As String = 4
Try
cnSQL.ConnectionString = GetOleDBConnectionString() ' This
function gets my connect string
cnSQL.Open()
sSQL = "update tblPayees " & _
" set paymentamt7 = paymentamount " & _
" where paymenttype like '*7' " & _
" and payerid = " & sPayer & _
" and (paymentamt7 = 0 or " & _
" paymentamt7 is null)"
cmd.Connection = cnSQL
cmd.CommandText = sSQL
iCount = cmd.ExecuteNonQuery()
Debug.WriteLine(iCount.ToString & " records had payments
moved to column " & X.ToString)
Next
When I look at the SQL statement executing, it looks like this -
update tblPayees set paymentamt7 = paymentamount where paymenttype like
'*7' and payerid = 4 and (paymentamt7 = 0 or paymentamt7 is null)
It updates zero rows, but when I paste that exact statement into an Access
query, it works correctly and updates my table. Anybody have any idea what
might be causing this?
executes, it does not error, but updates zero rows. If I take the statement
and paste it into my Access database as a Query and execute it, it updates
rows. My code is moving data from one column to another in the same table.
Dim cnSQL As New OleDbConnection
Dim cmd As New OleDbCommand
Dim sSQL As String
Dim iCount As Integer
Dim X As Integer
Dim sPayer As String = 4
Try
cnSQL.ConnectionString = GetOleDBConnectionString() ' This
function gets my connect string
cnSQL.Open()
sSQL = "update tblPayees " & _
" set paymentamt7 = paymentamount " & _
" where paymenttype like '*7' " & _
" and payerid = " & sPayer & _
" and (paymentamt7 = 0 or " & _
" paymentamt7 is null)"
cmd.Connection = cnSQL
cmd.CommandText = sSQL
iCount = cmd.ExecuteNonQuery()
Debug.WriteLine(iCount.ToString & " records had payments
moved to column " & X.ToString)
Next
When I look at the SQL statement executing, it looks like this -
update tblPayees set paymentamt7 = paymentamount where paymenttype like
'*7' and payerid = 4 and (paymentamt7 = 0 or paymentamt7 is null)
It updates zero rows, but when I paste that exact statement into an Access
query, it works correctly and updates my table. Anybody have any idea what
might be causing this?