很好,问题是清楚的,我希望,代码是这样的:我迷路了:这个ado.net代码有什么问题?
string sql = "delete from @tabelnaam";
SqlCommand sc = new SqlCommand();
sc.Connection = getConnection();
sc.CommandType = CommandType.Text;
sc.CommandText = sql;
SqlParameter param = new SqlParameter();
param.Direction = ParameterDirection.Input;
param.ParameterName = "@tabelnaam";
param.Value = tableName;
sc.Parameters.Add(param);
OpenConnection(sc);
sc.ExecuteScalar();
tablename是提供给该函数。
我得到异常:
Must declare the table variable @tabelnaam
是不是会导致sql注入? – Michel 2010-06-24 11:15:15
你可以通过验证表名正确来避免这种情况 – 2010-06-24 11:37:42