Click here to Skip to main content
15,890,506 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi, I'm wondering about this. I have a product table and when I add some product I used this code. Could this be safe in SQL Injection Attack.

Here is my code:

VB
Try

            Dim ta As New sampledbDSTableAdapters.productTableAdapter
            ta.Insert(TextBox1.Text, TextBox2.Text, TextBox3.Text, ComboBox1.SelectedValue)

            Me.DialogResult = Windows.Forms.DialogResult.OK
        Catch ex As Exception

            MsgBox(ex.Message)
            TextBox1.Focus()
        End Try
Posted
Comments
earloc 29-Nov-12 3:43am    
it depends on the implementation of sampledbDSTableAdapters.productTableAdapter.Insert - method

if it is generated, then it most likely will make use of SqlParameters to "inject" your provided values into the Insert-SqlStatement - and therfore should prevent most of the common SqlInjection scenarios.
joshrduncan2012 29-Nov-12 9:22am    
I agree, my suggestion would be to use Parameterized Queries.
ianshack 30-Nov-12 22:42pm    
thank you all for your ideas.

1 solution

On the surface, no, it's not safe. You're passing the values of TextBoxes to some method called .Insert, which probably doesn't scrub those values before putting them into the SQL statement.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900