> If you already have the datareader, there is no reason to use
> sqldatasource. Instead of databinding with DataSourceID, do with
> DataSource="<%# myReader %>" in the markup or
> myControl.DataSource=myReader; codebhind.
>
> --
> Eliyahu Goldin,
> Software Developer & Consultant
> Microsoft MVP [ASP.NET]
>
http://msmvps.com/blogs/egoldin >
http://usableasp.net >
>
> "Casper" <s@sd> wrote in message
> news:%2302kvkhSHHA.4872@TK2MSFTNGP03.phx.gbl...
>> Thanks for replying.
>> I did it in tthe aspx file but how can i link the sqlsource2 defined in
>> the aspx file to the data reader defined in the code-behind? I don't want
>> to redefine all the sql statement and parameter in the code-behind.
>> That's my problem.
>>
>>
>>
>>
>> "Eliyahu Goldin" <REMOVEALLCAPITALSeEgGoldDinN@mMvVpPsS.org> schreef in
>> bericht news:uCqzhjdSHHA.2188@TK2MSFTNGP03.phx.gbl...
>>> You can set the DataSourceMode attribute to DataReader and the
>>> sqldatasource will be using a datareader automatically. Is that what you
>>> are after?
>>>
>>>
>>> --
>>> Eliyahu Goldin,
>>> Software Developer & Consultant
>>> Microsoft MVP [ASP.NET]
>>>
http://msmvps.com/blogs/egoldin >>>
http://usableasp.net >>>
>>>
>>> "Casper" <s@sd> wrote in message
>>> news:eAuYzZdSHHA.5100@TK2MSFTNGP06.phx.gbl...
>>>> Hi,
>>>>
>>>> i know how to use datareader in code-behind, e.g. like this:
>>>>
>>>> Dim oConnection As OleDbConnection
>>>> Dim comd As OleDbCommand
>>>> Dim dtreader As OleDbDataReader
>>>>
>>>> oConnection = New OleDbConnection()
>>>> oConnection.ConnectionString = Application("connect")
>>>> oConnection.Open()
>>>>
>>>> sql = "SELECT * from table"
>>>> comd = New OleDbCommand(sql, oConnection)
>>>> dtreader = comd.ExecuteReader
>>>> ...
>>>>
>>>> This works perfect, but how to use dtreader when the datasource is
>>>> defined in the aspx file like this?
>>>> <asp:SqlDataSource ID="SqlDataSource1" runat="server"
>>>> ConnectionString="<%$ ConnectionStrings:cat %>"
>>>> SelectCommand="SELECT * table"></asp:SqlDataSource>
>>>>
>>>> I tried this in code-behind:
>>>> Dim dtreader As OleDbDataReader
>>>> dtreader=sqldatasource1.??? 'there is no ExecuteReader available
>>>> in the list
>>>>
>>>>
>>>> Thanks for helping.
>>>> Casper
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>