Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 13th, 2012, 09:31 AM
Registered User
 
Join Date: Jan 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Need help in Poll system in asp.net c#

hi all , i was looking for a poll system .. and i found this http://imar.spaanjaars.com/238/howto...x-with-c-sharp
it seem to be very help full but its written in Vb ,,, any one help me to re write it in c sharp ...
many thanks
Regards
 
Old January 13th, 2012, 03:05 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

I am not sure what you're asking. The article you linked to does not deal with a poll, and is written in C#. The articles on my site about a poll (or actually, a Rating control) are also available in C#.

So, what exactly are you looking for?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old January 14th, 2012, 06:28 AM
Registered User
 
Join Date: Jan 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Thanks for your replay

Dear Imar ,, thanks for you replay you are right , i just make mistake writing the question ..
my problem in the linked article is the instead of sql server you are used mdb file ..
my question is in the global.asax.cs file ..
how to modifiy it in order to use sql server instead of mdb file

kind regards
Syamand
 
Old January 14th, 2012, 06:44 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

I still don't understand what you're asking. Which article are you referring to now? The one you posted in your first post? Or yet another one?

In case of the former, you cannot simply switch to Access as you'll also need to rewrite the code. Searching Google for code to access an Access database should bring up lots of useful stuff.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old January 14th, 2012, 08:30 AM
Registered User
 
Join Date: Jan 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default hit counter problem

Dear Imar
thankks again

what i mean is this article ,..http://imar.spaanjaars.com/238/howto...x-with-c-sharp


and my problem is in the global.asax.cs file .. which the code is for mdb file and and working with sql server

the code below need to be modified and im begginer and dont know how to do it

using System;
using System.Data.sqlclient;
using System.Web;

namespace HitCounters
{
public class Global : HttpApplication
{
private static int totalNumberOfUsers;
private static int currentNumberOfUsers;



protected void Application_Start(object sender, EventArgs e)
{
// Get the Total Number of Users from the database.
string sql = "SELECT NumberOfHits FROM tblUserCounter WHERE CounterType = UserCounter";
using (SqlCommand command = new SqlCommand(sql, ConnectionManager.Getconnection()))
{

reader = command.ExecuteReader(CommandBehavior.SingleResult | CommandBehavior.CloseConnection);


}


if (reader.Read())
{
totalNumberOfUsers = reader.GetInt32(0);
}
else
{
totalNumberOfUsers = 0;
}
// Close the reader and the connection
reader.Close();
cmd.Connection.Close();
}






protected void Session_Start(object sender, EventArgs e)
{
// Increase the two counters.
totalNumberOfUsers += 1;
currentNumberOfUsers += 1;

// Save the Total Number of Users to the database.
string sql = "Update tblUserCounter set NumberOfHits = {0} where CounterType = UserCounter , totalNumberOfUser";
using (sqlcommand command = new sqlcommand (sql, ConnectionManager.GetConnection())
try
{

}
catch (sqlexception ex)
{
statusLabel.Text = ex.message;

}

}

protected void Application_BeginRequest(object sender, EventArgs e)
{

}

protected void Application_AuthenticateRequest(object sender, EventArgs e)
{

}

protected void Application_Error(object sender, EventArgs e)
{

}

protected void Session_End(object sender, EventArgs e)
{
currentNumberOfUsers -= 1;

}

protected void Application_End(object sender, EventArgs e)
{

}

/// <summary>
/// Gets the total number of users that visited this web site.
/// </summary>
public static int TotalNumberOfUsers
{
get
{
return totalNumberOfUsers;
}
}

/// <summary>
/// Gets the total number of users that are currently on-line.
/// </summary>
public static int CurrentNumberOfUsers
{
get
{
return currentNumberOfUsers;
}
}
}
}
 
Old January 14th, 2012, 08:55 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Yes, I understand, and I addressed that with:
Quote:
you cannot simply switch to Access as you'll also need to rewrite the code. Searching Google for code to access an Access database should bring up lots of useful stuff.
In other words, do a Google search on accessing an Access database and you'll find plenty of sample code. You'll need use classes such as the OleDbConnection.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old January 14th, 2012, 11:27 AM
Registered User
 
Join Date: Jan 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Need favorite please help me

Dear Imar , i really need your help to sort out this issue ...

i upload my file to this link ... could you modify it for me because im bigger and i tried many ways but failed ...

please do it for me ...
many thanks and much apreciated ...
 
Old January 15th, 2012, 08:01 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

This is a bit too off-topic for my book to discuss in this forum category. In addition, it's a bit too much code for me to write for you right now.

Did you follow my advice and search Google for code on how to access a Microsoft Access database?

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old January 15th, 2012, 08:37 AM
Registered User
 
Join Date: Jan 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default HitCounter Problem

Dear Imar ,,,

thanks again for your time .. and your concern .. actually its about a week im looking around to get a solutions or another tutorial regarding the hit counter ...
but i couldn't get the right thing what im looking for ... my past week was full of learning new things in visual studio and c sharp .. but its about 10 days i stopped learning new things and beside that im abut to forget what i was learning before .. because of this issue ... my thinking is fully busy with it and cant do any thing else...

the only Tutorial which was understandable for me was yours http://imar.spaanjaars.com/238/howto...x-with-c-sharp
but i faced this problem ...

so if you have time , could you please write another tutorial regarding this article , and this time use SQL server database instead of mdb file ... it will be great to have both option ...

many thanks again
Regards
 
Old January 15th, 2012, 09:23 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Don't count on such an article any time soon. I already have a few flavors of this article and adding yet another doesn't add a lot of value for me.

But like I said: there's a lot of useful material available:

http://www.google.nl/#sclient=psy-ab...+SqlConnection

Once you understand how to use objects like the SqlConnection (instead of the OleDbConnection) you'll find it easy to adapt the code from my article to SQL Server.

I wrote a few article series on connecting to SQL Server, but they are not targeted at beginners:

http://imar.spaanjaars.com/416/build...pnet-20-part-1
http://imar.spaanjaars.com/476/n-lay...l-introduction

Cheers.

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
poll System in C# Required msman88 ASP.NET 3.5 Professionals 2 August 30th, 2009 12:16 PM
I want poll System in C# msman88 BOOK: Professional ASP.NET 3.5 : in C# and VB ISBN: 978-0-470-18757-9 0 August 30th, 2009 08:45 AM
creating flagging system in asp.net Pawan Sharma Visual Studio 2005 0 September 12th, 2006 01:49 PM
VB .net or ASP(browser based) / suggestion/poll iniro VB.NET 2002/2003 Basics 3 September 26th, 2004 10:20 PM
System DSN Using in ASP.net ramacvs ADO.NET 0 September 14th, 2004 02:25 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.