Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 331
  • Last Modified:

execute sql statement in vb6

I would like to execute the following statement in vb6.  Will this code work?

esql = "update tblRegistration set NewPart = 1 Where ID in (SELECT tblRegistration.ID FROM AttendanceGrid INNER JOIN tblRegistration ON AttendanceGrid.[ID]=tblRegistration.[ID]Where  AttendanceGrid.Fiscal = '" & Fiscal & "' And AttendanceGrid.[CSW/TitleXX] = 'C' And AttendanceGrid.Month = '" & Com(z) & "' And NewPart = 0 And  Total > 0 And Combo11 like '" & rec1.Fields(0) & "')"

conn.Execute (esql)
0
al4629740
Asked:
al4629740
  • 2
2 Solutions
 
aikimarkCommented:
there needs to be a space here:
"tblRegistration.[ID]Where" -> "tblRegistration.[ID] Where"

Is there a field/column in your table named Combo11 ?

I suggest explicitly using the value property:
rec1.Fields(0) -> rec1.Fields(0).value

You are using a LIKE keyword in your SQL, but I do not see any pattern characters as part of the rec1.Fields(0) value you are concatenating.  If this the field does not contain wildcard characters, you will get faster performance using an equal comparison operation.
0
 
Arthur_WoodCommented:
is Combo11 a field on your form, of a field in a table in the Database?
0
 
al4629740Author Commented:
Thanks

Will this statement also execute it?

conn.Execute (esql)

Open in new window

0
 
Arthur_WoodCommented:
yes, that statement will execute the query (give the appropriate database connection), but the statement itself may not be valid.

AW
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now