在我的ASP.NET(3.5)項目中,我爲所有數據訪問使用內置的TableAdapters/Dataset。它是否提供與SQLDataSource從SQL注入相同的安全性?我使用的參數如下。TableAdapter/DataSet安全嗎?
Dim myDAL As New ABCTableAdapters.XYZTableAdapter
Label1.Text = myDAL.getDatafromDB(myParameter)
更新1:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim myParameter As String = getSafeURL(Request.QueryString("MS_Code")) 'getsafeurl encodes querystring using HttpUtility.UrlEncode
Dim myDAL As New ABCTableAdapters.XYZTableAdapter
Label1.Text = myDAL.getDatafromDB(myParameter)
End Sub
getDatafromDB對應於下面的查詢存在於的app_code/DAL.xsd
SELECT東西FROM sometable其中字段名= @parameter
更新2: 如果我查看XS的代碼D我可以看到以下
<SelectCommand>
<DbCommand CommandType="Text" ModifiedByUser="true">
<CommandText>SELECT pageContent FROM [content] where name = @name</CommandText>
<Parameters>
<Parameter AllowDbNull="true" AutogeneratedName="name" ColumnName="name" DataSourceName="iseac.dbo.[content]" DataTypeServer="nchar(100)" DbType="String" Direction="Input" ParameterName="@name" Precision="0" ProviderType="NChar" Scale="0" Size="100" SourceColumn="name" SourceColumnNullMapping="false" SourceVersion="Current" />
</Parameters>
</DbCommand>
</SelectCommand>
你能說明'getDatafromDB'方法是怎麼樣的嗎? –
@Darin Dimitrov - 請參考更新 –