【发布时间】:2013-10-05 08:42:55
【问题描述】:
您好,我想知道在SqlDataAdapter 中防止SQL injection 的最佳方法是什么(因为无法使用参数化查询)?
例如让我们使用这部分代码:
da_services = new SqlDataAdapter("SELECT * from table WHERE column='" + textBox1.Text + "' AND column2='" + somestring + "'", conn);
scd_services = new SqlCommandBuilder(da_services);
dt_services = new DataTable();
da_services.Fill(dt_services);
dtg_services.DataSource = dt_services;
conn.Close();
感谢您的宝贵时间。
【问题讨论】:
-
因为没有办法使用参数化查询。 Uh.......
标签: c# sql sql-server winforms