ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 31st, 2003, 02:03 AM
jsutta jsutta is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 6 jsutta User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
SQL DROP Syntax

Ok, now I have an ASP file that is part of a management script I've been working on. I'm using (or at least trying to use) the SQL DROP command, but no matter what I do, I can't make it work. Can someone take a look at it and tell me where I've messed up? Thanks for your help.

<%
Dim Mode,uid,uname

Mode = Request.QueryString("mode")
uid = Request.QueryString("uid")
uname = Request.QueryString("uname")
%>

<%
Dim cn,usr,SQL_usrtest

Set cn = Server.CreateObject("ADODB.Connection")
cn.Open = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("db/userlist.mdb")
Set usr = Server.CreateObject("ADODB.Recordset")

SQL_usrtest = "SELECT * FROM users WHERE uid=" & uid
usr.Open SQL_usrtest,cn,2,3
%>

<%
Dim cn1,ta,SQL_tatest

Set cn1 = Server.CreateObject("ADODB.Connection")
cn1.Open = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("db/tasks.mdb")
Set ta = Server.CreateObject("ADODB.Recordset")

SQL_tatest = "SELECT * FROM " & uname
ta.Open SQL_tatest,cn1,2,3
%>

<%
Dim SQL_ta

Select Case Mode
Case "edit"
Response.Write("edit")
usr("realname") = Request.Form("realname")
usr("pass") = Request.Form("password")
usr.Update
Case "delete"
Response.Write("del")
usr.delete
SQL_ta = "DROP TABLE " & uname
ta.Open SQL_ta,cn1,2,3
End Select
%>

Reply With Quote
  #2  
Old August 31st, 2003, 03:45 PM
karsh44's Avatar
karsh44 karsh44 is offline
Just another guy
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jun 2003
Location: Wisconsin
Posts: 2,915 karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 13 h 13 m 21 sec
Reputation Power: 76
First, you can't just say "It doesn't work". What are you trying to do, and what is actually happening? Are you getting an error? What error? Or just some unexpected result?
Until I know what you're trying to do, I'm not really going to get into the code, but it definitely looks unwieldy. Why are you making those 2 separate recordsets? Indent you case statements, it makes the code much easier to read.
__________________
--Dave--

U2kgSG9jIExlZ2VyZSBTY2lzLCBOaW1pdW0gRXJ1ZGl0aW9uaXMgSGFiZXM=

Reply With Quote
  #3  
Old August 31st, 2003, 04:51 PM
jsutta jsutta is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 6 jsutta User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hey karsh,
Thanks for the reply, sarcasm aside :-p. Usually I do indent my code, but when I pasted it in last night it didn't carry spacing with it, so that was lost, and it being somewhere in the neighborhood of 4:00 a.m., I was too tired to even realize that it would be a problem. The error I'm getting is an HTTP 500 error, nothing more, nothing less. I wouldn't have had to come here if it had given me a more specific error. I have two recordsets there because I'm manipulating data in two separate and, for security reasons, unlinked databases. What I really need help with is the syntax for the SQL DROP command. Everywhere I look I get one format, but for whatever reason it hasn't worked yet. Let's do this: forget my initial post and read this, then tell me what (if anything) is wrong with it. This is my understanding of the SQL DROP command.

Step 1:
Create a connection to the appropriate DB
Step 2: Execute a command with the following wording: 'DROP TABLE Name';
Step 3:
Close the connection

Is there anything else?

Reply With Quote
  #4  
Old August 31st, 2003, 05:08 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,829 Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 20 h 23 m 12 sec
Reputation Power: 765
If you are using Internet Explorer, open Tools - Internet Options - Advanced Options and uncheck the "show friendly http errors" setting. You should then get a more detailed explanation of the error you're getting when you run your code.

Reply With Quote
  #5  
Old August 31st, 2003, 05:26 PM
jsutta jsutta is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 6 jsutta User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Sweet :-) Good news, though. Thanks to karsh's criticism, I went through and cleaned the whole thing up and it now works flawlessly. Here's the code, as it works, for karsh to read so I can prove that sometimes I can come up with clean code lol. Btw, as I pasted it, it was spaced, so the spacing thing must not be on my end. Oh well, I suppose.

<%
Dim Mode,uid,uname

Mode = Request.QueryString("mode")
uid = Request.QueryString("uid")
uname = Request.QueryString("uname")
%>

<%
Dim usr

Set usr = Server.CreateObject("ADODB.Connection")
usr.Open = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("db/userlist.mdb")
%>

<%
Dim ta

Set ta = Server.CreateObject("ADODB.Connection")
ta.Open = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("db/tasks.mdb")
%>

<%
Dim SQL_usrupd,SQL_usrdel,SQL_tadel

Select Case Mode
Case "edit"
SQL_usrupd = "UPDATE users SET "
SQL_usrupd = SQL_usrupd & "realname='" & Request.Form("realname") & "', pass='" & Request.Form("password") & "' "
SQL_usrupd = SQL_usrupd & "WHERE uid=" & uid

usr.Execute SQL_usrupd
Case "delete"
SQL_usrdel = "DELETE * FROM users WHERE uid=" & uid
SQL_tadel = "DROP TABLE " & uname

usr.Execute SQL_usrdel
ta.Execute SQL_tadel
End Select
%>

<html>
<head>
<title></title>
<link rel="stylesheet" href="inc/stylesheet.css" class="text/css">
</head>

<body>

<font class="fontNormal">
Succesfully Updated Record<br>
<a href="intrafront.asp?login=true" class="fontLinksDark">Back to Front Page</a>
</font>

</body>

</html>

<%
usr.Close
Set usr = Nothing

ta.Close
Set ta = Nothing
%>

Reply With Quote
  #6  
Old August 31st, 2003, 06:35 PM
karsh44's Avatar
karsh44 karsh44 is offline
Just another guy
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jun 2003
Location: Wisconsin
Posts: 2,915 karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 13 h 13 m 21 sec
Reputation Power: 76
Glad it works, sometimes clean code helps for more than just looks .
For future reference, for posting code, put it in [code ] [/code ] (without the space) tags. This will preserve your spacing and tabs.
Cheers

Reply With Quote
  #7  
Old August 31st, 2003, 07:00 PM
jsutta jsutta is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 6 jsutta User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks karsh :-).

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > SQL DROP Syntax


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway