Created
July 1, 2013 15:24
-
-
Save scottsappen/5901810 to your computer and use it in GitHub Desktop.
ASP.Net SQL Server sql injection safety
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Dim connString As String = ConfigurationManager.ConnectionStrings("your_database").ConnectionString | |
| Dim sqlString As String = "" | |
| Dim sqlConnection As New SqlConnection(connString) | |
| sqlString = "insert into [ss].[dbo].[MyGuestBook] (firstName) values (@firstName);" | |
| Dim sqlCommand As New SqlCommand(sqlString, sqlConnection) | |
| Dim paramFirstName = New SqlParameter("firstName", SqlDbType.VarChar) | |
| paramFirstName.Value = inputFromUserCleanedFirstName | |
| sqlCommand.Parameters.Add(paramFirstName) | |
| sqlConnection.Open() | |
| sqlCommand.ExecuteScalar() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment