473,386 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

2 different datalists on same aspx page

I'm trying to display two different datalists on the same page; only
the first datalist displays, while the second does not display (and it
does have data matching the where clause):

<%@ Page Language="vb" Debug="true"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OLEDB" %>
<script language="VB" runat="server">
Sub Page_Load(Src As Object, E As EventArgs)
dim todd = DateTime.Today.ToString ( "d" )
Dim strConn as string ="Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\mydbase.mdb;"
Dim strSQL as string ="SELECT article, articleheader, articleID
FROM articles WHERE (dept = 'news') AND (articledate = #" & todd & "#)"

Dim Conn as New OLEDBConnection(strConn)
Dim Cmd as New OLEDBCommand(strSQL,Conn)
Conn.Open()
thedata.DataSource =
Cmd.ExecuteReader(system.data.CommandBehavior.Clos eConnection)
thedata.DataBind()
End Sub
</script>
<html>
<head> <title>datalist test</title>
</head>

<body>
<asp:DataList id="thedata" runat="server"
RepeatColumns="1" RepeatDirection="vertical"
CellSpacing="3">
<ItemTemplate>
<b><%# Container.DataItem("articleheader")%></b>
<br><br><%# Container.DataItem("article")%>

</ItemTemplate>
</ASP:Datalist>

<script language="VB" runat="server">
sub t2
dim todd2 = DateTime.Today.ToString ( "d" )
Dim strConn as string ="Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\mydbase.mdb;"
Dim strSQL as string ="SELECT article, articleheader, articleID
FROM articles WHERE (dept = 'features') AND (articledate = #" & todd2 &
"#)"
Dim Conn as New OLEDBConnection(strConn)
Dim Cmd as New OLEDBCommand(strSQL,Conn)
Conn.Open()
thedata2.DataSource =
Cmd.ExecuteReader(system.data.CommandBehavior.Clos eConnection)
thedata2.DataBind()
end sub
</script>

<asp:DataList id="thedata2" runat="server"
RepeatColumns="1" RepeatDirection="vertical"
CellSpacing="3">
<ItemTemplate>
<b><%# Container.DataItem("articleheader")%></b>
<br><br><%# Container.DataItem("article")%>
</ItemTemplate>
</ASP:Datalist>
</body></html>

thanks in advance
chumley

Nov 19 '05 #1
5 1213
Try putting the sub t2 into the page_load event

"Chumley Walrus" wrote:
I'm trying to display two different datalists on the same page; only
the first datalist displays, while the second does not display (and it
does have data matching the where clause):

<%@ Page Language="vb" Debug="true"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OLEDB" %>
<script language="VB" runat="server">
Sub Page_Load(Src As Object, E As EventArgs)
dim todd = DateTime.Today.ToString ( "d" )
Dim strConn as string ="Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\mydbase.mdb;"
Dim strSQL as string ="SELECT article, articleheader, articleID
FROM articles WHERE (dept = 'news') AND (articledate = #" & todd & "#)"

Dim Conn as New OLEDBConnection(strConn)
Dim Cmd as New OLEDBCommand(strSQL,Conn)
Conn.Open()
thedata.DataSource =
Cmd.ExecuteReader(system.data.CommandBehavior.Clos eConnection)
thedata.DataBind()
End Sub
</script>
<html>
<head> <title>datalist test</title>
</head>

<body>
<asp:DataList id="thedata" runat="server"
RepeatColumns="1" RepeatDirection="vertical"
CellSpacing="3">
<ItemTemplate>
<b><%# Container.DataItem("articleheader")%></b>
<br><br><%# Container.DataItem("article")%>

</ItemTemplate>
</ASP:Datalist>

<script language="VB" runat="server">
sub t2
dim todd2 = DateTime.Today.ToString ( "d" )
Dim strConn as string ="Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\mydbase.mdb;"
Dim strSQL as string ="SELECT article, articleheader, articleID
FROM articles WHERE (dept = 'features') AND (articledate = #" & todd2 &
"#)"
Dim Conn as New OLEDBConnection(strConn)
Dim Cmd as New OLEDBCommand(strSQL,Conn)
Conn.Open()
thedata2.DataSource =
Cmd.ExecuteReader(system.data.CommandBehavior.Clos eConnection)
thedata2.DataBind()
end sub
</script>

<asp:DataList id="thedata2" runat="server"
RepeatColumns="1" RepeatDirection="vertical"
CellSpacing="3">
<ItemTemplate>
<b><%# Container.DataItem("articleheader")%></b>
<br><br><%# Container.DataItem("article")%>
</ItemTemplate>
</ASP:Datalist>
</body></html>

thanks in advance
chumley

Nov 19 '05 #2
Try putting the sub t2 into the page_load event

"Chumley Walrus" wrote:
I'm trying to display two different datalists on the same page; only
the first datalist displays, while the second does not display (and it
does have data matching the where clause):

<%@ Page Language="vb" Debug="true"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OLEDB" %>
<script language="VB" runat="server">
Sub Page_Load(Src As Object, E As EventArgs)
dim todd = DateTime.Today.ToString ( "d" )
Dim strConn as string ="Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\mydbase.mdb;"
Dim strSQL as string ="SELECT article, articleheader, articleID
FROM articles WHERE (dept = 'news') AND (articledate = #" & todd & "#)"

Dim Conn as New OLEDBConnection(strConn)
Dim Cmd as New OLEDBCommand(strSQL,Conn)
Conn.Open()
thedata.DataSource =
Cmd.ExecuteReader(system.data.CommandBehavior.Clos eConnection)
thedata.DataBind()
End Sub
</script>
<html>
<head> <title>datalist test</title>
</head>

<body>
<asp:DataList id="thedata" runat="server"
RepeatColumns="1" RepeatDirection="vertical"
CellSpacing="3">
<ItemTemplate>
<b><%# Container.DataItem("articleheader")%></b>
<br><br><%# Container.DataItem("article")%>

</ItemTemplate>
</ASP:Datalist>

<script language="VB" runat="server">
sub t2
dim todd2 = DateTime.Today.ToString ( "d" )
Dim strConn as string ="Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\mydbase.mdb;"
Dim strSQL as string ="SELECT article, articleheader, articleID
FROM articles WHERE (dept = 'features') AND (articledate = #" & todd2 &
"#)"
Dim Conn as New OLEDBConnection(strConn)
Dim Cmd as New OLEDBCommand(strSQL,Conn)
Conn.Open()
thedata2.DataSource =
Cmd.ExecuteReader(system.data.CommandBehavior.Clos eConnection)
thedata2.DataBind()
end sub
</script>

<asp:DataList id="thedata2" runat="server"
RepeatColumns="1" RepeatDirection="vertical"
CellSpacing="3">
<ItemTemplate>
<b><%# Container.DataItem("articleheader")%></b>
<br><br><%# Container.DataItem("article")%>
</ItemTemplate>
</ASP:Datalist>
</body></html>

thanks in advance
chumley

Nov 19 '05 #3
I get an "ExecuteReader requires an open and available Connection. The
connection's current state is Closed" error when trying to combine the
two subs. Not sure what is involved with putting two subs in one
page_load

Nov 19 '05 #4
I get an "ExecuteReader requires an open and available Connection. The
connection's current state is Closed" error when trying to combine the
two subs. Not sure what is involved with putting two subs in one
page_load

Nov 19 '05 #5
See what happens if you give the second connection another name - I use
strconnection1 and strconnection2 with success - -
"Chumley Walrus" <sp*******@yahoo.com> wrote in message
news:11*********************@l41g2000cwc.googlegro ups.com...
I get an "ExecuteReader requires an open and available Connection. The
connection's current state is Closed" error when trying to combine the
two subs. Not sure what is involved with putting two subs in one
page_load

Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Jonathan Hollinger | last post by:
Very, very strange problem. In developing a C# ASP.NET application, every so often, DataLists disappear from the build. They remain visible and rendered (though sometimes dropping properties and...
0
by: Jonathan Hollinger | last post by:
Very, very strange problem. In developing a C# ASP.NET application, every so often, DataLists disappear from the build. They remain visible and rendered (though sometimes dropping properties and...
1
by: tshad | last post by:
I am trying understand when DataLists ItemCreated is called. I put function that attaches a popup to my delete button: Sub DataList_ItemCreated(Sender As Object, e As DataListItemEventArgs)...
3
by: webserverpete | last post by:
I am new to ASP.NET in general, but I do have experience with classic ASP. I am using a DataList control with a hidden value to submit to a different page, however I do not know how to get to that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.