【发布时间】:2018-03-27 02:41:33
【问题描述】:
Private Sub recruit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles recruit.Click
Dim query3 As String
Dim n As Integer
Dim query2 As String = "select max(stag) from agent"
con.ConnectionString = ("Data Source=DESKTOP-CTN5IJ3\SQLEXPRESS;Integrated Security=True")
Dim autono As New SqlCommand(query2, con)
con.Open()
If IsDBNull(autono.ExecuteScalar) Then
n = 7
Else
n = autono.ExecuteScalar + 5
End If
con.Close()
query3 = "insert into agent values(" + n + ",'" + ncrypt(txtssn.Text) + "','" + ncrypt(txtname.Text) + "','" + ncrypt(txtadd.Text) + "',0,0,'newbpwd')"
Dim save As New SqlCommand(query3, con)
con.Open()
save.ExecuteNonQuery()
con.Close()
End Sub
//query3 = "插入代理值(" + n + ",'" + ncrypt(txtssn.Text) + "','" + ncrypt(txtname.Text) + "','" + ncrypt( txtadd.Text) + "',0,0,'newbpwd')" 这就是问题所在
【问题讨论】:
-
您的代码也容易受到 SQL 注入的攻击。请改用parameterized queries。
-
Re SQL 注入,参见:Exploits of a Mom aka "Little Bobby Tables"。