Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Community Discussions (All other subjects)
 Getting stats into a .net grid view
 New Topic  Reply to Topic
 Printer Friendly
Next Page
Author Previous Topic Topic Next Topic
Page: of 2

thermal_seeker
Junior Member

United Kingdom
430 Posts

Posted - 14 June 2010 :  17:36:39  Show Profile  Reply with Quote
If this is the wrong place to post this... I apologise

I am trying to get the Member count, Forum count, Topic count and post count into a .NET datagrid on a webpage outside of the forum. It seems that I cannot draw the info directly from the database tables, so would I have to create a page that writes the stats into a new database table and draw from that or is there a simple way to do this??

No good at coding, but I can plough a field !!

HuwR
Forum Admin

United Kingdom
20595 Posts

Posted - 15 June 2010 :  02:18:10  Show Profile  Visit HuwR's Homepage  Reply with Quote
I can't see why you would want to display this information in a gridview it is not data that would lend itself to being tabulated, you are basically just trying to display 3 distinct values, so why put it in a grid ?

If you really must display it in a grid, create yourelf an object with three properties, fill the properties by interrogating the db and then assign your object to the grids data source ( even though you don't want one you will need to create a list of your object even though there is only one since you can't assign a singleton object as a datasource)

MVC .net dev/test site | MVC .net running on Raspberry Pi
Go to Top of Page

thermal_seeker
Junior Member

United Kingdom
430 Posts

Posted - 15 June 2010 :  17:00:17  Show Profile  Reply with Quote
I suppose I was thinking that a grid would look ok at the bottom of my page!! However, just a single line at the bottom of my page would be ok displaying those 4 results.

so if I re-phrase this: How easy is it to put those details on a page (VB .NET) outside of the forum.

Please bear in mind I'm a ploughman and not a coder

No good at coding, but I can plough a field !!
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20595 Posts

Posted - 15 June 2010 :  17:40:00  Show Profile  Visit HuwR's Homepage  Reply with Quote
fairly simple, I have a usercontrol and some queries you can probably use, I'll dig them out

MVC .net dev/test site | MVC .net running on Raspberry Pi
Go to Top of Page

thermal_seeker
Junior Member

United Kingdom
430 Posts

Posted - 16 June 2010 :  01:15:09  Show Profile  Reply with Quote
Thanks HuwR

No good at coding, but I can plough a field !!
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20595 Posts

Posted - 16 June 2010 :  03:09:09  Show Profile  Visit HuwR's Homepage  Reply with Quote
I will make it into a control that you can just plonk on a page and configure via the webconfig, that should make it easier for you. What exactly do you want to be able to show, the control I have currently basically replicates the stats section at the bottom of default.asp


MVC .net dev/test site | MVC .net running on Raspberry Pi
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20595 Posts

Posted - 16 June 2010 :  03:10:33  Show Profile  Visit HuwR's Homepage  Reply with Quote
I may not be able to show all that info as some of that relies on it using .net membership providers (members online for example)

also what version of .net is your site using?

MVC .net dev/test site | MVC .net running on Raspberry Pi
Go to Top of Page

Carefree
Advanced Member

Philippines
4217 Posts

Posted - 16 June 2010 :  03:22:05  Show Profile  Reply with Quote
Here you go. You will have to change the connection string to point to your database (& the table prefixes if you modified them). Other than that, it will give you a table with your data.


<%
'###############################################################################
'##
'##			Snitz Forums 2000 v3.4.07
'##
'###############################################################################
'##
'## Copyright © 2000-06 Michael Anderson, Pierre Gorissen,
'##			Huw Reddick and Richard Kinser
'##
'## This program is free. You can redistribute and/or modify it under the
'## terms of the GNU General Public License as published by the Free Software
'## Foundation; either version 2 or (at your option) any later version.
'##
'## All copyright notices regarding Snitz Forums 2000 must remain intact in
'## the scripts and in the HTML output.	The "powered by" text/logo with a
'## link back to http://forum.snitz.com in the footer of the pages MUST
'## remain visible when the pages are viewed on the internet or intranet.
'##
'## This program is distributed in the hope that it will be useful but
'## WITHOUT ANY WARRANTY; without even an implied warranty of MERCHANTABILITY
'## or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
'## for more details.
'##
'## You should have received a copy of the GNU General Public License along
'## with this program; if not, write to:
'##
'##			Free Software Foundation, Inc.
'##			59 Temple Place, Suite 330
'##			Boston, MA 02111-1307
'##
'## Support can be obtained from our support forums at:
'##
'##			http://forum.snitz.com
'##
'## Correspondence and marketing questions can be sent to:
'##
'##			manderson@snitz.com
'##
'###############################################################################

'## Make sure to uncomment one of the strConnString lines and edit it so that it points to where your database is!

'strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("dbase/snitz_forums_2000.mdb")         '## MS Access 2000 using virtual path
'strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("/USERNAME/db/snitz_forums_2000.mdb")  '## MS Access 2000 on Brinkster
'strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\inetpub\dbase\snitz_forums_2000.mdb"                   '## MS Access 2000 using physical path
'strConnString = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("dbase/snitz_forums_2000.mdb")        '## MS Access 97 using virtual path
'strConnString = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("/USERNAME/db/snitz_forums_2000.mdb") '## MS Access 97 on Brinkster
'strConnString = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=c:\inetpub\dbase\snitz_forums_2000.mdb"                  '## MS Access 97 using physical path
'strConnString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Server.MapPath("dbase/snitz_forums_2000.accdb")      '## MS Access 2007 using virtual path
'strConnString = "Provider=SQLOLEDB;Data Source=SERVER_NAME;database=DB_NAME;uid=UID;pwd=PWD;"                           '## MS SQL Server 6.x/7.x/2000 (OLEDB connection)
'strConnString = "driver={SQL Server};server=SERVER_NAME;uid=UID;pwd=PWD;database=DB_NAME"                               '## MS SQL Server 6.x/7.x/2000 (ODBC connection)
'strConnString = "Provider=SQLNCLI;server=SERVER_NAME;database=DB_NAME;uid=UID;pwd=PWD;"                                 '## MS SQL Server 2005 w/ SQL Native Client
'strConnString = "driver={MySQL ODBC 3.51 Driver};option=16387;server=SERVER_IP;user=UID;password=PWD;DATABASE=DB_NAME;" '## MySQL w/ MyODBC v3.51
'strConnString = "driver=MySQL;server=SERVER_IP;uid=UID;pwd=PWD;database=DB_NAME"                                        '## MySQL w/ MyODBC v2.50
'strConnString = "DSN_NAME"                                                                                              '## DSN

'###############################################################################
'## SELECT YOUR TABLE PREFIXES
'###############################################################################

strTablePrefix = "FORUM_"
strMemberTablePrefix = "FORUM_"

set my_Conn = Server.CreateObject("ADODB.Connection")
my_Conn.Open strConnString
strSql = "SELECT COUNT(TOPIC_ID) AS CNT FROM " & strTablePrefix & "TOPICS WHERE T_STATUS = 1 "
set rsTopic=my_Conn.Execute(strSql)
if not rsTopic.EOF then
	intTopicCount=rsTopic("CNT")
end if
rsTopic.Close
set rsTopic = Nothing
strSql = "SELECT COUNT(REPLY_ID) AS CNT FROM " & strTablePrefix & "REPLY WHERE R_STATUS = 1 "
set rsReply=my_Conn.Execute(strSql)
if not rsReply.EOF then
	intReplyCount=rsReply("CNT")
end if
rsReply.Close
set rsReply = Nothing
strSql = "SELECT COUNT(MEMBER_ID) AS CNT FROM " & strMemberTablePrefix & "MEMBERS WHERE M_STATUS = 1 "
set rsMembers=my_Conn.Execute(strSql)
if not rsMembers.EOF then
	intMemberCount=rsMembers("CNT")
end if
rsMembers.Close
set rsMembers = Nothing
strSql = "SELECT COUNT(FORUM_ID) AS CNT FROM " & strTablePrefix & "FORUM WHERE F_STATUS = 1 "
set rsForum=my_Conn.Execute(strSql)
if not rsForum.EOF then
	intForumCount=rsForum("CNT")
end if
rsForum.Close
set rsForum = Nothing
Response.write	"<table width=""60%"" align=""center"" border=""1"" bgcolor=""black"">" & vbNewLine & _
	"	<tr valign=""middle"">" & vbNewLine & _
	"		<td align=""center"" colspan=""4"" bgcolor=""ltcyan"">" & vbNewLine & _
	"			<font face=""arial"" size=""4"" color=""black"">Forum Statistics" & vbNewLine & _
	"			</font>" & vbNewLine & _
	"		</td>" & vbNewLine & _
	"	</tr>" & vbNewLine & _
	"	<tr valign=""middle"">" & vbNewLine & _
	"		<td align=""center"" width=""25%"" bgcolor=""ltgreen"">" & vbNewLine & _
	"			<font face=""arial"" size=""3"" color=""black""><b>Forums</b>" & vbNewLine & _
	"			</font>" & vbNewLine & _
	"		</td>" & vbNewLine & _
	"		<td align=""center"" width=""25%"" bgcolor=""ltgreen"">" & vbNewLine & _
	"			<font face=""arial"" size=""3"" color=""black""><b>Members</b>" & vbNewLine & _
	"			</font>" & vbNewLine & _
	"		</td>" & vbNewLine & _
	"		<td align=""center"" width=""25%"" bgcolor=""ltgreen"">" & vbNewLine & _
	"			<font face=""arial"" size=""3"" color=""black""><b>Posts</b>" & vbNewLine & _
	"			</font>" & vbNewLine & _
	"		</td>" & vbNewLine & _
	"		<td align=""center"" width=""25%"" bgcolor=""ltgreen"">" & vbNewLine & _
	"			<font face=""arial"" size=""3"" color=""black""><b>Topics</b>" & vbNewLine & _
	"			</font>" & vbNewLine & _
	"		</td>" & vbNewLine & _
	"	</tr>" & vbNewLine & _
	"	<tr valign=""middle"">" & vbNewLine & _
	"		<td align=""center"" width=""25%"" bgcolor=""white"">" & vbNewLine & _
	"			<font face=""arial"" size=""2"" color=""black""><b>"& intForumCount &"</b>" & vbNewLine & _
	"			</font>" & vbNewLine & _
	"		</td>" & vbNewLine & _
	"		<td align=""center"" width=""25%"" bgcolor=""white"">" & vbNewLine & _
	"			<font face=""arial"" size=""2"" color=""black""><b>"& intMemberCount &"</b>" & vbNewLine & _
	"			</font>" & vbNewLine & _
	"		</td>" & vbNewLine & _
	"		<td align=""center"" width=""25%"" bgcolor=""white"">" & vbNewLine & _
	"			<font face=""arial"" size=""2"" color=""black""><b>"& intTopicCount+intReplyCount &"</b>" & vbNewLine & _
	"			</font>" & vbNewLine & _
	"		</td>" & vbNewLine & _
	"		<td align=""center"" width=""25%"" bgcolor=""white"">" & vbNewLine & _
	"			<font face=""arial"" size=""2"" color=""black""><b>"& intTopicCount &"</b>" & vbNewLine & _
	"			</font>" & vbNewLine & _
	"		</td>" & vbNewLine & _
	"	</tr>" & vbNewLine & _
	"</table>" & vbNewLine
%>
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20595 Posts

Posted - 16 June 2010 :  04:39:03  Show Profile  Visit HuwR's Homepage  Reply with Quote
that is classic asp not .net

MVC .net dev/test site | MVC .net running on Raspberry Pi
Go to Top of Page

Carefree
Advanced Member

Philippines
4217 Posts

Posted - 16 June 2010 :  04:41:41  Show Profile  Reply with Quote
Whoops - read the request and ignored the parameters lol.
Go to Top of Page

thermal_seeker
Junior Member

United Kingdom
430 Posts

Posted - 16 June 2010 :  13:13:06  Show Profile  Reply with Quote
quote:
Originally posted by HuwR

I may not be able to show all that info as some of that relies on it using .net membership providers (members online for example)

also what version of .net is your site using?



.NET 2.0 (with 3.0 and 3.5 extensions installed)

I'm not worried about members online.. the 2 main ones would be the member count and forum count. The topic count would be a bonus.

ie. we currently have xxx members
there are xxx forums with xxx topics

That would do it nicely... I'm a plain and simple man

Thanks Huw

Dave

No good at coding, but I can plough a field !!
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20595 Posts

Posted - 16 June 2010 :  13:22:29  Show Profile  Visit HuwR's Homepage  Reply with Quote
ok cool, will try and get it done this evening

MVC .net dev/test site | MVC .net running on Raspberry Pi
Go to Top of Page

thermal_seeker
Junior Member

United Kingdom
430 Posts

Posted - 16 June 2010 :  17:34:00  Show Profile  Reply with Quote
Thanks Huw.. there really is no rush.... I'm snowed under with farming work at the moment :(

No good at coding, but I can plough a field !!
Go to Top of Page

thermal_seeker
Junior Member

United Kingdom
430 Posts

Posted - 24 June 2010 :  14:48:04  Show Profile  Reply with Quote
Any luck with this yet Huw??

Dave

No good at coding, but I can plough a field !!
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20595 Posts

Posted - 25 June 2010 :  02:30:46  Show Profile  Visit HuwR's Homepage  Reply with Quote
Sorry, been very busy with work, but will definitely sort it out for you over the weekend.

MVC .net dev/test site | MVC .net running on Raspberry Pi
Go to Top of Page

thermal_seeker
Junior Member

United Kingdom
430 Posts

Posted - 25 June 2010 :  05:21:22  Show Profile  Reply with Quote
no worries thank you

Dave

No good at coding, but I can plough a field !!
Go to Top of Page
Page: of 2 Previous Topic Topic Next Topic  
Next Page
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.24 seconds. Powered By: Snitz Forums 2000 Version 3.4.07