Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SqlBulkCopy and protection from SQL injection

I need to insert multiple rows at the same time (1000 rows) into a SQL Server database. I think best way is to use SqlBulkCopy but I'm not sure how to parametrize insert queries to be safe from SQL injection.

Can you please help me? What is best way to perform multiple insert statements (SQL injection safe)?

Thank you.

like image 638
user2980426 Avatar asked May 12 '15 19:05

user2980426


People also ask

What protects against SQL injection?

Developers can prevent SQL Injection vulnerabilities in web applications by utilizing parameterized database queries with bound, typed parameters and careful use of parameterized stored procedures in the database. This can be accomplished in a variety of programming languages including Java, . NET, PHP, and more.

What is SqlBulkCopy in SQL?

Microsoft SQL Server includes a popular command-line utility named bcp for quickly bulk copying large files into tables or views in SQL Server databases. The SqlBulkCopy class allows you to write managed code solutions that provide similar functionality.

What are 5 types of SQL injection?

Types of SQL Injections. SQL injections typically fall under three categories: In-band SQLi (Classic), Inferential SQLi (Blind) and Out-of-band SQLi. You can classify SQL injections types based on the methods they use to access backend data and their damage potential.

Does encryption protect against SQL injection?

Cryptography is one of the dominant techniques to prevent SQL injection attacks. All the confidential data are encrypted and stored in the database; even if the hacker gains access to the database, he/she cannot be able to decrypt the data without the knowledge of algorithm and key used to encrypt the data.


1 Answers

The best way to insert multiple rows is by using SqlBulkCopy.

The SqlBulkCopy class is already safe from SQL Injection. So you don't have to worry about this.

like image 196
Jonathan Magnan Avatar answered Oct 17 '22 03:10

Jonathan Magnan