SQL 주입을 피하는 방법을 모르겠지만 누군가 내 문제를 해결할 수 있습니까? 특히 사용자의 입력에서 오는 즉, 취약, SQL 문을 만들어 함께Visual Basic 2010의 SQL 삽입
Private Function INSERT() As String
Dim SQLcon As New SqlConnection
Dim SQLdr As SqlDataReader
Try
SQLcon.ConnectionString = "Data Source=#####;Initial Catalog=OJT;Persist Security Info=True;User ID=####;Password=#####"
Dim SQLcmd As New SqlCommand("INSERT INTO dbo.Patients(pIDNo,pLName,pFName,pMI,pSex,pStatus,pTelNo,pDocID,pAddr,pStreet,pBarangay,pCity,pProvince,pLNameKIN,pFNameKIN,pMIKIN,pRelationKIN) VALUES('" & LabelPNumber.Text & "','" & txtLname.Text & "','" & txtFname.Text & "','" & txtMI.Text & "','" & txtPatientSex.Text & "','" & txtPatientSex.Text & "','" & txtPatientTelNo.Text & "','" & txtPatientDoctor.Text & "','" & txtStreetNumber.Text & "','" & txtStreetName.Text & "','" & txtBarangay.Text & "','" & txtCity.Text & "','" & txtProvince.Text & "','" & txtKinLname.Text & "','" & txtKinFname.Text & "','" & txtKinMI.Text & "','" & txtRelationToPatient.Text & "') ", SQLcon)
SQLcon.Open()
MsgBox("Patient Added!", MsgBoxStyle.Information)
SQLdr = SQLcmd.ExecuteReader()
Catch ex As Exception
MessageBox.Show("Error Occured, Can't Add Patient!" & ex.Message)
Finally
SQLcon.Close()
End Try
Return "done"
End Function
사용 [파라미터 (http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.parameters.aspx) – rene
매개 변수 sir rene을 사용하는 SELECT STATEMENT의 예는 무엇입니까? – Danjor
을 다른 동료가 지정한대로 sql-parameters를 사용하십시오. 나는 오늘 당신의 관심사 일 수도있는 [이 다른 질문] (http://stackoverflow.com/a/14660347/1203135)에 대한 샘플을 썼습니다. –