Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Adding data to different cats. in a DB
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Adding data to different cats. in a DB

 Post Reply Post Reply Page  12>
Author
worldwide1504 View Drop Down
Groupie
Groupie
Avatar

Joined: 15 July 2002
Location: United States
Status: Offline
Points: 55
Post Options Post Options   Thanks (0) Thanks(0)   Quote worldwide1504 Quote  Post ReplyReply Direct Link To This Post Topic: Adding data to different cats. in a DB
    Posted: 12 December 2003 at 7:50am

Hi.

I followed the Guestbook tutorial from this site, but instead of using it as a guestbook I made it a picture gallery.

I can succesfully add, edit, and delete pics after logging in.

But it only adds them to a certain category in the DB. And I have about 4 or 5 categories.

 

So the question is, when I add an image through the form...How can I make a drop down box that picks that category the pictures goes under?

Back to Top
aalavar View Drop Down
Groupie
Groupie


Joined: 08 December 2003
Status: Offline
Points: 46
Post Options Post Options   Thanks (0) Thanks(0)   Quote aalavar Quote  Post ReplyReply Direct Link To This Post Posted: 12 December 2003 at 10:25am

Are the categories stored in the database, or do you just want to manually create a list of categories using HTML to insert into the database?  Also, if you can post the db fields in the table that holds the category I will try to help.

Back to Top
worldwide1504 View Drop Down
Groupie
Groupie
Avatar

Joined: 15 July 2002
Location: United States
Status: Offline
Points: 55
Post Options Post Options   Thanks (0) Thanks(0)   Quote worldwide1504 Quote  Post ReplyReply Direct Link To This Post Posted: 12 December 2003 at 10:33am

I just had the categories as seperate tables:

game, music, other, tvmovies.

And there are images in each on. And I want to have drop down box that picks what image goes in what table/category.

 

Could I do something with booleans? So when someone picks a categroy from the drop down it sets it to true. And then on the next update page it says something like:

if blnGameCategory=true then
    add to game category
else if ...

Would that work?

 



Edited by worldwide1504
Back to Top
aalavar View Drop Down
Groupie
Groupie


Joined: 08 December 2003
Status: Offline
Points: 46
Post Options Post Options   Thanks (0) Thanks(0)   Quote aalavar Quote  Post ReplyReply Direct Link To This Post Posted: 12 December 2003 at 10:55am

Add this to your form to add the drop down box:

<select name=catgy>
<option value="GAME">Game</option>
<option value="MUSIC">Music</option>
<option value="OTHER">Other</option>
<option value="TVMOVIES">TV Movies</option>
</select>

In the update page you can use a case statement to determine your table

category = Request("catgy")
case select category
 case "GAME"
  strSQL="select * from game"
 case "MUSIC"
  strSQL="select * from music"
 case "OTHER"
  strSQL="select * from other"
 case "TVMOVIES"
  strSQL="select * from tvmovies"
end select

The rest of the code shouldn't be changed...

Back to Top
worldwide1504 View Drop Down
Groupie
Groupie
Avatar

Joined: 15 July 2002
Location: United States
Status: Offline
Points: 55
Post Options Post Options   Thanks (0) Thanks(0)   Quote worldwide1504 Quote  Post ReplyReply Direct Link To This Post Posted: 12 December 2003 at 11:29am

Ok, it says that there is a:

Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

on this line

rsAddIcon.Open strSQL, adoCon



Edited by worldwide1504
Back to Top
aalavar View Drop Down
Groupie
Groupie


Joined: 08 December 2003
Status: Offline
Points: 46
Post Options Post Options   Thanks (0) Thanks(0)   Quote aalavar Quote  Post ReplyReply Direct Link To This Post Posted: 12 December 2003 at 11:43am

Do this before the open statement:

Response.write strSQL

it should display the sql statement you are trying to perform.  Also, post the whole code before that point and I'll see if I can figure it out.  Or you can e-mail me both files (aalavar@bellsouth.net), I will see what the problem is. 

Back to Top
worldwide1504 View Drop Down
Groupie
Groupie
Avatar

Joined: 15 July 2002
Location: United States
Status: Offline
Points: 55
Post Options Post Options   Thanks (0) Thanks(0)   Quote worldwide1504 Quote  Post ReplyReply Direct Link To This Post Posted: 12 December 2003 at 12:16pm

That Response.Write doesnt seem to do anything thing...but here is the code:

 


<%
'If the session variable is False or does not exsist then redirect the user to the unauthorised user page
If Session("blnIsUserGood") = False or IsNull(Session("blnIsUserGood")) = True then
 'Redirect to unathorised user page
 Response.Redirect"../default.asp"
End If
%>

<%
'Dimension variables
Dim adoCon               'Holds the Database Connection Object
Dim rsAddIcon        &nb sp;  'Holds the recordset for the new record to be added
Dim strSQL               'Holds the SQL query to query the database

'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("../db/Icons.mdb")

'Create an ADO recordset object
Set rsAddIcon = Server.CreateObject("ADODB.Recordset")

select case category
 case "GAME"
  strSQL = "SELECT game.url, game.name FROM game;"
 case "MUSIC"
  strSQL = "SELECT music.url, music.name FROM music;"
 case "OTHER"
  strSQL = "SELECT other.url, other.name FROM other;"
 case "TVMOVIES"
  strSQL = "SELECT tvmovie.url, tvmovie.name FROM tvmovies;"
end select

'Set the cursor type we are using so we can navigate through the recordset
rsAddIcon.CursorType = 2

'Set the lock type so that the record is locked by ADO when it is updated
rsAddIcon.LockType = 3

'Open the recordset with the SQL query
rsAddIcon.Open strSQL, adoCon


Back to Top
aalavar View Drop Down
Groupie
Groupie


Joined: 08 December 2003
Status: Offline
Points: 46
Post Options Post Options   Thanks (0) Thanks(0)   Quote aalavar Quote  Post ReplyReply Direct Link To This Post Posted: 12 December 2003 at 12:56pm

before your "Select case category" you need to request it... Add this line:

category = Request("catgy")

Where catgy was the name of the drop down box (if you copied and pasted mine, that was the name I used).

Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.