VB6和SQL - ODBC驱动程序不支持请求的属性
问题描述:
我正在开发一个学校项目的程序,它是基于“如何使用SQL Server与VB6(包括选择&插入)”视频的Youtube 。VB6和SQL - ODBC驱动程序不支持请求的属性
程序看起来像这样:
点击单选按钮使相邻的文本框,并禁用其余(除大文本框然后,搜索按钮内,下面的代码是。嵌入式:
Dim aConnection As New ADODB.Connection
Dim aRecSet As New ADODB.Recordset
Private Sub cmdSearch_Click()
If txtStuNum.Enabled = True Then
aRecSet.Open "select * from studentTable where studentNumber'" & txtDisplay.Text & "'", aConnection, adOpenKeyset
ElseIf txtName.Enabled = True Then
aRecSet.Open "select * from studentTable where Name'" & txtDisplay.Text & "'", aConnection, adOpenKeyset
ElseIf txtGrade.Enabled = True Then
aRecSet.Open "select * from studentTable where Grade'" & txtDisplay.Text & "'", aConnection, adOpenKeyset
ElseIf txtSection.Enabled = True Then
aRecSet.Open "select * from studentTable where section'" & txtDisplay.Text & "'", aConnection, adOpenKeyset
End If
End Sub
当我按下搜索按钮,这个弹出:
所有回复赞赏!谢谢!
答
你忘了=
迹象,形式为:
where field = 'string'
此代码是开放的SQL注入攻击,如果一个文本框,包含在'
性格不好的事情都可能发生。使用参数&命令对象来避免这种情况,请参阅this。
嗨,谢谢你的回答!但是,当我添加“=”时,它仍然显示相同的错误。而关于',我个人认为这是好的,因为我不指望任何人使用这个特定的角色。对此问题有更多可能的答案吗?谢谢! – 2015-01-18 11:04:02
尝试删除'adOpenKeySet',而改为:'aRecSet.Open'select * from studentTable where section ='“&txtDisplay.Text&”'“,aConnection,adOpenStatic,adLockReadOnly' – 2015-01-18 14:34:15
应该解决''''问题,一个SQL注入漏洞,并可能允许恶意用户从数据库中删除数据; http://*.com/questions/601300/what-is-sql-injection – 2015-01-18 14:37:11