Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
|
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 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 July 4th, 2005, 12:42 PM
Authorized User
 
Join Date: Jun 2005
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

 
Old July 4th, 2005, 11:47 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
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

 
Old July 6th, 2005, 09:38 AM
Authorized User
 
Join Date: Jun 2005
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

 
Old July 6th, 2005, 09:44 AM
Authorized User
 
Join Date: Jun 2005
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



 
Old July 8th, 2005, 10:01 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
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





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 04:29 PM
Handle Email UPdates sanjeet General .NET 0 February 2nd, 2005 05:18 PM
Unable to login - Email address not registered ??! xrow Forum and Wrox.com Feedback 2 November 19th, 2004 06: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





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