VB 6 Verification, sql insert
Hi
I have this code below:
Set cnHPtest = New ADODB.Connection
With cnHPtest
.Provider = strDBProv
.ConnectionString = strDBString
.CommandTimeout = 1000
.Open
End With
'If txtSalary.Text <> " " And txtmCover <> " " And txtMember.Text <> " " And txtmRate.Text <> " " Then
' MsgBox "Welcome"
tsql = "INSERT INTO Hpacc4(SalaryBill,Rate,Membership,Cover) " & _
"VALUES('" & txtSalary.Text & "','" & txtmCover & "', '" & txtMember.Text & "', '" & txtmRate.Text & "')" & _
"WHERE Scheme = '99993' AND RunMonth = '200604' AND AccCode = '110'"
cnHPtest.Execute (tsql)
'Else
' MsgBox "Enter Values"
'End If
I have of problems with this code.
1. When I run only the inner part of it:
tsql = "INSERT INTO Hpacc4(SalaryBill,Rate,Membership,Cover) " & _
"VALUES('" & txtSalary.Text & "','" & txtmCover & "', '" & txtMember.Text & "', '" & txtmRate.Text & "')" & _
"WHERE Scheme = '99993' AND RunMonth = '200604' AND AccCode = '110'"
I get and error that there is a problem with my where clause, which would mean I didn't write the code correctly, please help.
2. when I un-comment the whole code and try to run, my verification fails, I always get MsgBox "Welcome" even when my text fields are empty
|