【发布时间】:2018-02-01 16:03:41
【问题描述】:
我在添加数据 oracle 数据库时遇到问题,它向我显示此消息(“https://ufile.io/lzpuj”)运行时 ORA-00904:“EMPCODE”:无效标识符。 这是科迪:
Dim connEmp As ADODB.Connection
Dim rsEmp As ADODB.Recordset
Private Sub Command1_Click()
Set rsEmp = New ADODB.Recordset
rsEmp.Open "select * from tablebooks where empcode = '" & Text1.Text & "'",
connEmp, adOpenKeyset, adLockReadOnly, adCmdText
If rsEmp.RecordCount <> 0 Then
MsgBox " ! åÐÇ ÇáßÊÇÈ ãæÌæÏ ÈÇáÝÚá "
rsEmp.Close
Set rsEmp = Nothing
Exit Sub
Else
Set rsEmp = New ADODB.Recordset
rsEmp.Open "select * from tablebooks where empcode = '" & Text1.Text & "'",
connEmp, adOpenKeyset, adLockPessimistic, adCmdText
rsEmp.AddNew
rsEmp!Book_no = Val(Trim(Text1.Text))
rsEmp!Book_name = Trim(Text2.Text)
rsEmp!Author_name = Trim(Text10.Text)
rsEmp!Edition_no = Val(Trim(Text3.Text))
rsEmp!Publisher_place = Trim(Text11.Text)
rsEmp!Part_no = Val(Trim(Text5.Text))
rsEmp!Book_cost = Trim(Text6.Text)
rsEmp!Place_book = Trim(Text7.Text)
rsEmp!Note = Trim(Text9.Text)
rsEmp!Date_publishing = DTPicker1.Value
rsEmp!Subject = Trim(Combo4.Text)
rsEmp!State = Trim(Combo4.Text)
rsEmp.Update
connEmp.Execute "commit"
rsEmp.Close
Set rsEmp = Nothing
Label11.Visible = True
Label11 = " ! ÊãÊ ÇáÅÖÇÝÉ ÈäÌÇÍ "
End If
End Sub
【问题讨论】:
-
看起来
tablebooks没有名为empcode的列。 (或者,它是使用双引号列名创建的,例如"empcode"或"empCode"- 如果是这样,您必须以完全相同的方式引用它,包括大小写和双引号。) -
是的,我相信它正在查看的您的桌子没有它。另外作为一些友好的建议,这段代码很容易受到 SQL 注入攻击。我建议使用参数集合来提供 Text1.Text 的值,以防有人偷偷摸摸。
-
这将非常容易受到 sql 注入攻击。
-
此外,链接ufile.io/lzpuj 不起作用。