3

我需要帮助解决我的 vba 更新语句问题:

在我的表单中,我有一个单击表单,当我单击它时执行此过程:

Dim strSQL As String
 Dim rst As New ADODB.Recordset

  strSQL = "UPDATE dbo.Firma_test SET Fax = " & Me![subforma_companie].Form!fax & _
          "[E-mail] = " & Me![subforma_companie].Form!email & _
          "WHERE Company_Code = " & Me![subforma_companie].Form!Cod

当我执行时,我告诉我他没有看到电子邮件字段,我该怎么办???

4

1 回答 1

2

WHERE子句前需要一个空格:

strSQL = "UPDATE dbo.Firma_test SET Fax = " & Me![subforma_companie].Form!fax & _
      ", [E-mail] = '" & Me![subforma_companie].Form!email & _
      "' WHERE Company_Code = " & Me![subforma_companie].Form!Cod

此外,您可能需要考虑某种形式的预防措施,SQL Injection以防万一用户DROP TABLE db.Firma_test输入subforma_companie form

于 2013-04-16T11:38:39.167 回答