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 4 11383
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@sdwrote in message
news:eA**************@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
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" <RE**************************@mMvVpPsS.orgschree f in
bericht news:uC**************@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@sdwrote in message
news:eA**************@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
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@sdwrote in message
news:%2****************@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" <RE**************************@mMvVpPsS.orgschree f in
bericht news:uC**************@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@sdwrote in message news:eA**************@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
Thanks
"Eliyahu Goldin" <RE**************************@mMvVpPsS.orgschree f in
bericht news:eW****************@TK2MSFTNGP03.phx.gbl...
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@sdwrote in message
news:%2****************@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" <RE**************************@mMvVpPsS.orgschree f in bericht news:uC**************@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@sdwrote in message news:eA**************@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
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: zapov |
last post by:
Hi!
Did anyone successfully managed to use some custom ADO.NET
provider with SqlDataSource? I'd like to connect to some
other database than MSSQL (like MySQL, Firebird or PostgreSQL)
but I'm...
|
by: staeri |
last post by:
Hello!
I would like to set the SqlDataSource in the code behind file and not
to have it in the aspx file. How can I do that?
Regards,
Staeri
|
by: Dorte |
last post by:
Hi,
Could someone help me with a couple of links to SqlDatasource documentation
on how to use the Gridview and SqlDatasource components in code behind?
Basically I'm missing some documentation...
|
by: VB Programmer |
last post by:
Asp.net 2.0...
I have an SqlDataSource on my aspx form. It's defined as...
<asp:SqlDataSource ID="sdsCoupons" runat="server" ConnectionString="<%$
ConnectionStrings:ConnectionString %>"...
|
by: Matt Colegrove |
last post by:
I'm working on a web app that is published to a hosting service. I'm
developing it on my local PC with VS 2005 and SQL Express. The hosting
service DB is SQL Server 2000.
I have two...
|
by: phil |
last post by:
Hi,
I want to put a recordset in a gridview but i don't know how to pass the
value of the variable in the 'where' statement. The value of the variable is
set in the code-behind. i added a tag...
|
by: msch-prv |
last post by:
Hi, I am trying to tie a SQLDataSource control to MySQL without
success. The connection string works ok with an ObjectDataSource.
(Native asp.net 2.0 MySQL dll loaded in /bin)
For some reason,...
|
by: djc |
last post by:
1) I am wondering if I should be using an sqlDataSource object for my
particular scenario. I need to loop through a listbox and perform an INSERT
sql operation for each item. Could be a few or...
|
by: Jason Huang |
last post by:
Hi,
Here is my SqlDataSource in my C#.2.0 aspx file:
<asp:SqlDataSource ID="SqlDataSourceA" runat="server" ConnectionString="<%$
ConnectionStrings:GConnectionStringA %>"
SelectCommand="SELECT...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |