How to run multiple SQL commands in a single SQL connection?

前端 未结 9 992
野的像风
野的像风 2020-11-27 15:03

I am creating a project in which I need to run 2-3 SQL commands in a single SQL connection. Here is the code I have written:

SqlConnection con = new SqlConn         


        
9条回答
  •  無奈伤痛
    2020-11-27 15:43

    This is likely to be attacked via SQL injection by the way. It'd be worth while reading up on that and adjusting your queries accordingly.

    Maybe look at even creating a stored proc for this and using something like sp_executesql which can provide some protection against this when dynamic sql is a requirement (ie. unknown table names etc). For more info, check out this link.

提交回复
热议问题