日期:2014-05-18  浏览次数:20531 次

带参数的sqldatasource如何转化为dataset?
不带参数的sqldatasource可以用下面语句来转化为dataset
C# code
DataView dv = (DataView)DSAlbum.Select(DataSourceSelectArguments.Empty);


可是当sqldatasource带参数时以上语句出错
我的sqldatasource定义为:
C# code
    <asp:SqlDataSource ID="DSAlbum" runat="server" ConnectionString="<%$ ConnectionStrings:Jigu_ConnectionString %>"
        SelectCommand="SELECT album.aldate, album.acomp, album.adisc, album.aintro, album.aname, artist.aname AS artist, lang.laname, cate.catname, artist.aid, picture.pname, picture.pdir, picture.psid FROM album INNER JOIN cate ON album.acate = cate.catid INNER JOIN lang ON album.alan = lang.lanid INNER JOIN artist ON album.arid = artist.aid INNER JOIN picture ON album.alid = picture.psid WHERE (picture.psize = 'M') and alid=@id">
        <SelectParameters>
            <asp:QueryStringParameter Name="newparameter" QueryStringField="id" DefaultValue="1" />
        </SelectParameters>
    </asp:SqlDataSource>


错误提示“必须声明变量 '@id'。”,请问该如何声明?

------解决方案--------------------
试一试

<SelectParameters>
<asp:QueryStringParameter Name="id" QueryStringField="id" DefaultValue="1" />
</SelectParameters>