Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old July 4th, 2005, 12:42 PM
Authorized User
 
Join Date: Jun 2005
Location: , , .
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default Check if user is registered for email updates

Hello,

I know there is an example in the ASP.NET 1.1 ... Wrox book about checking whether the user has alread registered for updates. I implimented the example in the book, but it didnt seem to work so well. There must be another way of doing it without using cookies.

I just want the code to check if the user is alread in the database. I am using c#. I should think i need to use an IF statment, but how?

Brett:D

Reply With Quote
  #2 (permalink)  
Old July 4th, 2005, 11:47 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,346
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Use a simple select query to check for a user against your table:

Select count(*)
From <table>
Where <col> = @userid

then use an if statement to do what you want to do based on the result

Reply With Quote
  #3 (permalink)  
Old July 6th, 2005, 09:38 AM
Authorized User
 
Join Date: Jun 2005
Location: , , .
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I tried using the select command below,

strCommand = "SELECT [Addressbook].[email] FROM [Addressbook] WHERE [Addressbook].[email] = @txtFrom.Text";

however it didnt seem to collecting data from the txtFrom textbox, it gave me an error that:

No value given for one or more required parameters.

To view the code:
http://www.sks.co.za/workingEMAIL4.aspx

Brett

Reply With Quote
  #4 (permalink)  
Old July 6th, 2005, 09:44 AM
Authorized User
 
Join Date: Jun 2005
Location: , , .
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry, I forgot that the code will be rendered in html.

here is the code:

           OleDbConnection objConnection;
           OleDbDataAdapter objCommand;
           String strConnect;
           String strCommand;
           DataSet DataSet1 = new DataSet();

                      //Connect to access database
           strConnect = @"Provider=Microsoft.Jet.OLEDB.4.0;";
           strConnect += @"Data Source="+Server.MapPath("//db//sks1.mdb")+";";
           strConnect += @"Persist Security Info=False";
           objConnection = new OleDbConnection(strConnect);


           strCommand = "SELECT [Addressbook].[email] FROM [Addressbook] WHERE [Addressbook].[email] = @txtFrom.Text";
           objCommand = new OleDbDataAdapter(strCommand, objConnection);
           objCommand.Fill(DataSet1, "Addressbook");

Thanks

Brett



Reply With Quote
  #5 (permalink)  
Old July 8th, 2005, 10:01 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,413
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You can't put a control property in a literal string like that. .NET doesn't implicitly figure out that you are referring to an object. You need to concatenate the value like this:

strCommand = "SELECT [Addressbook].[email] FROM [Addressbook] WHERE [Addressbook].[email] = '" & txtFrom.Text & "'";

-Peter
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Email Register for Updates HelpWanted ASP.NET 1.0 and 1.1 Basics 3 October 31st, 2006 03:29 PM
Handle Email UPdates sanjeet General .NET 0 February 2nd, 2005 04:18 PM
Unable to login - Email address not registered ??! xrow Forum and Wrox.com Feedback 2 November 19th, 2004 05:28 AM
Email Updates from Excel pstaffeld Excel VBA 1 August 20th, 2003 07:09 AM
Check registered components at run-time jacob Classic ASP Components 0 July 5th, 2003 07:50 AM



All times are GMT -4. The time now is 07:32 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.