很好,問題是清楚的,我希望,代碼是這樣的:我迷路了:這個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