Results 1 to 8 of 8

Thread: Visual Studio 2005

  1. #1
    Funking Prink! Raz316's Avatar
    Join Date
    Jul 2003
    Location
    Deal, Kent, UK
    Posts
    2,978
    Thanks
    130
    Thanked
    62 times in 52 posts

    Visual Studio 2005

    Right, some uni project work requires me to make an ecommerce site, what I would like to do is allow the user to clicka button and display a random entry ...

    I was thinking return a random number between 1 and [total entries in product table] and redirect to details?id=[number]

    I am at a loss as to how to do this though and its getting frustrating now. I have a tableadapter that does correctly count the number of entries but I dont know how to reference it.

    I know thats not entirely clear, but hopefully someone will understand.

    thanks

  2. #2
    Agent of the System ikonia's Avatar
    Join Date
    May 2004
    Location
    South West UK (Bath)
    Posts
    3,736
    Thanks
    39
    Thanked
    75 times in 56 posts
    It is Inevitable.....


  3. #3
    Funking Prink! Raz316's Avatar
    Join Date
    Jul 2003
    Location
    Deal, Kent, UK
    Posts
    2,978
    Thanks
    130
    Thanked
    62 times in 52 posts
    cheers, C# ASP.net infront of a Microsoft Access Database

  4. #4
    Flower Child stytagm's Avatar
    Join Date
    Aug 2004
    Location
    London
    Posts
    754
    Thanks
    47
    Thanked
    23 times in 18 posts
    Ummm?
    Code:
    string newUrl = String.Format("/details?id={0}",GetMyRandomNumber());
    Response.Redirect(newUrl);
    Assuming you're having trouble with the random number, not the redirect, something like this:

    Code:
    private int GetMyRandomNumber()
    {
       int randomNumber = 0;
       Thread.Sleep(1); //(bounces the clock a bit to jig the Random number)
       Random rand = new Random();
       randomNumber = rand.Next(0,myTableAdapter.count())
       
       return randomNumber;
    }
    This is off the top of my head, so don't just paste it into some code, it almost certainly won't work. Also, I'm not really familiar with Dataadaptors, it's the kind of thing I look up when I need to (rarely). So it might have .length() instead of .Count() etc, or you may even have to iterate through the rows to count them, I have no idea

    you'll need to add "using System.Threading;" to the top of your file or else the little thread.sleep bit won't work. Or you could just leave that statement out, it's not really vital.

    Next up, Access? I mean, do you have to? Couldn't you use SQL server express instead? Or MySQL? Or anything in fact that isn't Access?

    Lastly, if you're at Uni, are you using the grown up Visual Studio 2005, or the Express version?
    Last edited by stytagm; 07-12-2006 at 06:58 PM. Reason: Tidying up
    They told me I was gullible ... and I believed them.

  5. #5
    Sublime HEXUS.net
    Join Date
    Jul 2003
    Location
    The Void.. Floating
    Posts
    11,819
    Thanks
    213
    Thanked
    233 times in 160 posts
    • Stoo's system
      • Motherboard:
      • Mac Pro
      • CPU:
      • 2*Xeon 5450 @ 2.8GHz, 12MB Cache
      • Memory:
      • 32GB 1600MHz FBDIMM
      • Storage:
      • ~ 2.5TB + 4TB external array
      • Graphics card(s):
      • ATI Radeon HD 4870
      • Case:
      • Mac Pro
      • Operating System:
      • OS X 10.7
      • Monitor(s):
      • 24" Samsung 244T Black
      • Internet:
      • Zen Max Pro
    If you're using VS2005 why not use the internal SQL Server database?

    Access really is a bag of crap
    (\__/)
    (='.'=)
    (")_(")

  6. #6
    Funking Prink! Raz316's Avatar
    Join Date
    Jul 2003
    Location
    Deal, Kent, UK
    Posts
    2,978
    Thanks
    130
    Thanked
    62 times in 52 posts
    cheers sty, the problem is I am afraid much simpler than that, Im struggling to retrieve the number of entries in the product table. I've got the query written for it as part of a tableadapter and the actual SQL statement works, however I am struggling to get this into variable form so I can specify the highest number in the random command.

    Stoo: haha i did wonder that, but im just following the assignment

  7. #7
    Funking Prink! Raz316's Avatar
    Join Date
    Jul 2003
    Location
    Deal, Kent, UK
    Posts
    2,978
    Thanks
    130
    Thanked
    62 times in 52 posts
    thanks again sty, that function is exactly what I need

    oh and the bit I was struggling with...
    Code:
    ProductsTableAdapters.ProductsTableAdapter AA = new
            ProductsTableAdapters.ProductsTableAdapter();
            int noitems = (int)AA.CountProducts();
    was as simple as that!

  8. #8
    Flower Child stytagm's Avatar
    Join Date
    Aug 2004
    Location
    London
    Posts
    754
    Thanks
    47
    Thanked
    23 times in 18 posts
    Hi Raz,

    Glad you got it sorted. I'll be honest, the Tableadaptor had me beaten, so I'm glad you solved that bit

    Cheers - Andrew. (Or sty)

    Edit: btw, which namespace is the tableadaptor in? I had a very brief look in System.Data.Common, but couldn't find it, is it an Access specific jobbie or am I being thick?
    Last edited by stytagm; 08-12-2006 at 08:54 PM. Reason: Thought of a question
    They told me I was gullible ... and I believed them.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. FREE Visual Studio Express from M$
    By megah0 in forum Retail Therapy and Bargains
    Replies: 15
    Last Post: 12-11-2005, 02:28 PM
  2. MS launches SQL Server 2005, Visual Studio
    By Steve in forum HEXUS News
    Replies: 4
    Last Post: 07-11-2005, 12:33 PM
  3. Visual Studio 2005 is out...
    By dangel in forum Software
    Replies: 25
    Last Post: 02-11-2005, 04:51 PM
  4. Visual Studio 2005 Beta 1
    By Shad in forum Software
    Replies: 4
    Last Post: 30-07-2004, 09:05 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •