Wrox Programmer Forums
|
BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6
This is the forum to discuss the Wrox book ASP.NET 2.0 Instant Results by Imar Spaanjaars, Paul Wilton, Shawn Livermore; ISBN: 9780471749516
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 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 May 16th, 2006, 12:50 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 Stuart,

Glad it's working. Very weird indeed.

Not sure what you're asking about stored procedures. Are you referring to procedures like sp_adduser and sp_grantlogin?

If so, look up sp_adduser in SQL Server's Books Online. It comes with plenty of explanation and example and at the bottom of the page you'll find See Also links that take you to other related procedures.

HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
 
Old May 17th, 2006, 12:07 PM
Authorized User
 
Join Date: May 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Imar,

It is okay I was looking for the SP to create a new Membership User, all done now.

One more question. If is add a new Function in ShopManagerDB.vb to return the products based on a description, what would the line:

- theProduct = New Product(myReader.GetString(myReader.GetOrdinal("De scription")), ?)

Need to read. The Stored Procedure is there and working, the form works, and passing the variable works.

Just need to know how I get ALL returned products in the list.

I OWE YOU ONE FOR YOU HELP!

Thanks in advance,

Stuart.

 
Old May 18th, 2006, 03:34 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

I am not sure what you're asking. Do you want to return a list of products matching a certain description??

In that case, you could create an overload of GetProducts, like this:

Public Shared Function GetProducts(ByVal description As String) _
  As List(Of Product)

End Function

Inside that method, you'd use code similar to the present GetProducts method, but instead of passing the categoryId, you pass the search term / description to the stored proc.

Then inside the method, you construct the Product instance based on its Id and category (still). However, instead of getting the category Id from the parameter, you get it from the reader:

theProduct = New Product( _
    myReader.GetInt32(myReader.GetOrdinal("Id")), _
        myReader.GetInt32(myReader.GetOrdinal("CategoryId" )))


Does that help?

Imar

---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
 
Old May 19th, 2006, 09:13 AM
Authorized User
 
Join Date: May 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Imar,

Excellent worked a dream thanks. My next job is to change it to have the products (and their images) customisable.

Thanks again,

Stuart.

 
Old May 21st, 2006, 03:49 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 Stuart,

You're welcome.

You could take a look at chapter 5 - The Wrox CMS. It demonstrates a number of CMS features that may come in handy when building a management tool for the products in the Web Shop.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
 
Old May 23rd, 2006, 05:29 AM
Authorized User
 
Join Date: May 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Imar,

Chapter 5 was a real help. Just getting my head around the "HTTPContext.Current.Session". Updating lists and the screen displaying the cached items.

I'll get there.

Stuart.

 
Old May 23rd, 2006, 11:18 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 Stuart,

Glad you found chapter 5 useful. It's a chapter that features a lot of useful concepts that you can use in other (database driven) sites as well.

HttpContext.Current is used to get access to stuff like Server, Response etc. Normally, you get access to these classes through the Page class you're working with.

So, when you use Request.QueryString, you could also use Page.Request.QueryString, or even this.Request.QueryString because they have been made available as properties of the Page class.

In a class file in the App_Code folder, you can't access these classes directly. Because your own class inherits from Object, it doesn't have these handy properties. That's where HttpContext.Current comes in. HttpContext.Current points to the current HTTP context in which the class in the App_Code folder executes. The Current property in turn gives you access to stuff like Request, Server and so on.

So, to cut a long story short, in pages you use Request.QueryString, while in classes in the App_Code folder you need to use HttpContext.Current.QueryString. The same applies to the other classes like Server and Response.

Note that this more or less breaks proper n-tier design. Let's say you created a class library (similar to the App_Code folder) that you want to reuse in multiple applications. When you have code that access the HttpContext, it will break when the class library is reused in, say, a Windows Forms application, because in that application, there is no HTTP context.

However, since you're using this in an App_Code folder inside a web application, you probably won't reuse that code in another application, so things should work for you.

Does this clarify things?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
 
Old May 23rd, 2006, 11:26 AM
Authorized User
 
Join Date: May 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Imar,

Once again a very clear response. The problem I am having is that I have created another page like the /shop/products.aspx. But when I do a delete I still get the same items, even though the database has updated. Unlike yours where you get the list to update.

How?

Stuart.

 
Old May 23rd, 2006, 11:33 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 Stuart,

(Maybe we should start a separate thread for this topic, as a) the page becomes pretty long and b) it's no longer related to the original topic).

Anyway, with the Products page, the single data source takes care of it all. It sees that an item is deleted, and then it refreshes the list.

If you have a separate control for the Delete action and the Select action, you may need to sync the two. The easiest way to accomplish that is in the Deleted event of the ObjectDataSource control, like this:

protected void ObjectDataSource1_Deleted(object sender,
      ObjectDataSourceStatusEventArgs e)
{
  GridView1.DataBind();
}

It's C#, but I am sure you get the idea. This tells the GridView to get fresh data from its data source control which in turn will get it from the data source.

This assumes that you are using a GridView, and separate data source controls. Lot's of assumptions, so if this doesn't help, can you post some of your code?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004





Similar Threads
Thread Thread Starter Forum Replies Last Post
Webshop gogetsome BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 2 March 7th, 2008 03:07 PM
Database Design Question about WebShop learningASP.Net BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 8 August 9th, 2007 01:05 AM
WebShop (Chap 9) Question about Login SDonnelly BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 3 October 19th, 2006 04:12 AM
modifying Webshop mlevans BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 3 September 23rd, 2006 05:12 AM





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