Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   Pulling out 10 last posts in forum (access db) (http://www.velocityreviews.com/forums/t95977-pulling-out-10-last-posts-in-forum-access-db.html)

Daniel Jahro via DotNetMonster.com 02-03-2005 07:42 PM

Pulling out 10 last posts in forum (access db)
 
Hi!

Im trying to pull out the last ten posts in a access dg (*.mdb). Whats the best way to do it?

All posts are located in a table named "tblTopic" and the posts automatically get accending numbers. The first vertical row (?) with the numbers are named "Topic_ID".

Any ideas?

Thanks in advance!
-daniel

--
Message posted via http://www.dotnetmonster.com

Gopal \(FMS, Inc.\) 02-03-2005 08:32 PM

Re: Pulling out 10 last posts in forum (access db)
 
Select top 10 * from tblTopic order by Topic_ID desc

You need to run the above query from an aspx page and populate a datagrid.

Hope this gets you on the right track.
--
Gopal Rangaswamy
Microsoft Certified Solutions Developer
FMS, Inc.
<http://www.fmsinc.com/consulting>
<http://www.fmsinc.com/dotnet/SourceBook/>

"Daniel Jahro via DotNetMonster.com" <forum@DotNetMonster.com> wrote in
message news:9d6db6c46bf64c7fa84cf49bb4afa4a5@DotNetMonste r.com...
> Hi!
>
> Im trying to pull out the last ten posts in a access dg (*.mdb). Whats the

best way to do it?
>
> All posts are located in a table named "tblTopic" and the posts

automatically get accending numbers. The first vertical row (?) with the
numbers are named "Topic_ID".
>
> Any ideas?
>
> Thanks in advance!
> -daniel
>
> --
> Message posted via http://www.dotnetmonster.com




Daniel Jahro via DotNetMonster.com 02-03-2005 08:56 PM

Re: Pulling out 10 last posts in forum (access db)
 
Heh, i guess, but im pritty new to this, so could you by any chance be somewhat more specific? :)

--
Message posted via http://www.dotnetmonster.com

John Timney \(ASP.NET MVP\) 02-03-2005 09:15 PM

Re: Pulling out 10 last posts in forum (access db)
 
The code below might help.....change the database name and it might just
work.....

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director


<%@ Page Language="VB"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>

<script language="VB" runat="server">
Sub Page_Load(Src as object, E as EventArgs)

Dim objConnection As OleDbConnection
Dim objCommand As OleDbCommand
Dim objDataReader As OleDbDataReader
Dim strSQLQuery As String

objConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=" & Server.MapPath("database.mdb") & ";")

strSQLQuery = "Select top 10 * from tblTopic order by Topic_ID desc"

objCommand = New OleDbCommand(strSQLQuery, objConnection)

objConnection.Open()

objDataReader = objCommand.ExecuteReader(CommandBehavior.CloseConn ection)

resultsGrid.DataSource = objDataReader
resultsGrid.DataBind()

End Sub

</script>

<html>
<body>

<asp:DataGrid id="resultsGrid" runat="server"
cellspacing="1"
cellpadding="2"
HeaderStyle-Font-Bold="True"
ToolTip="This is Cool!"
MaintainViewState="false"
/>

</body>
</html>



"Daniel Jahro via DotNetMonster.com" <forum@DotNetMonster.com> wrote in
message news:04a80517001940ac92a2c8b4583bc62c@DotNetMonste r.com...
> Heh, i guess, but im pritty new to this, so could you by any chance be

somewhat more specific? :)
>
> --
> Message posted via http://www.dotnetmonster.com





Daniel Jahro via DotNetMonster.com 02-03-2005 09:32 PM

Re: Pulling out 10 last posts in forum (access db)
 
Where? :)

--
Message posted via http://www.dotnetmonster.com

Patrick Olurotimi Ige 02-03-2005 11:43 PM

Re: Pulling out 10 last posts in forum (access db)
 
Daniel with the code John gave u below:-
Change this 2 lines:-

objConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=" & Server.MapPath("database.mdb") & ";")

strSQLQuery = "Select top 10 * from tblTopic order by Topic_ID desc"

change the database.mdb to your database name!
And thats it..
Hope it helps
Patrick





Sub Page_Load(Src as object, E as EventArgs)

Dim objConnection As OleDbConnection
Dim objCommand As OleDbCommand
Dim objDataReader As OleDbDataReader
Dim strSQLQuery As String

objConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=" & Server.MapPath("database.mdb") & ";")

strSQLQuery = "Select top 10 * from tblTopic order by Topic_ID desc"

objCommand = New OleDbCommand(strSQLQuery, objConnection)

objConnection.Open()

objDataReader =
objCommand.ExecuteReader(CommandBehavior.CloseConn ection)

resultsGrid.DataSource = objDataReader
resultsGrid.DataBind()

End Sub

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Daniel Jahro via DotNetMonster.com 02-04-2005 09:29 AM

Re: Pulling out 10 last posts in forum (access db)
 
Thanks! Im trying to get it to work..

--
Message posted via http://www.dotnetmonster.com

Patrick Olurotimi Ige 02-04-2005 10:17 PM

Re: Pulling out 10 last posts in forum (access db)
 
Hi Daniel Jahro,
Good u are trying..'
Any more questions let me know.
Patrick



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


All times are GMT. The time now is 11:54 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.