Dude, I know you're going to be like "Geez, does this girl know anything!" But it's a work in progress! This only my second-third week working with ASP and SQL -- it's pretty cool though. Anyways, back to the matter at hand....
Okay, I've gotten everything doing what I originally wanted it to do! Now I'm trying to enhance it a bit. I figure the more implementing and things I do with this the more information I'll retain, so I'll be able to do it in the future with pages actually related to my job. Programmer in training ;) Some of this I learned already in school, but researching all of this really opens my eyes to how much they DIDN'T teach us!
Well, this is what I'm trying to do now...(and I'm researching it on the internet and in my books, but sometimes the syntax I find won't work properly in my program, so I have to search a little more, sometimes alter it, or whatever just to make it work).....
Okay, now I've got FOUR pages: Tables.asp, ViewTable.asp, InsertCategory.asp, DeleteCategory.asp
I've got it viewing the table you select and I can Insert a category name and delete it from the database... NOWWW what I wanted to do was do a validation check on the Category name before it is inserted or deleted. If the table already exist when I try to insert it I want a msgbox to appear informing the user of this; never leaving the Insert Page. Once user pushes OK the box goes away and he/she is still at the Insert page to attempt to type in ANOTHER Category name to insert. If the name doesn't exist then it will add it to the database; msgbox reappears informing the user that the category name had been added to the table. NEVER leaving the Insert page. I want to do this same thing for deleting a Category name. If it doesn't exist I want the user to be informed, but I also want the page to stay on the delete category page, etc, etc. (The user can choose to continue deleting or inserting data or they'll be able to click the "view changes" button and it will take them back to the tables page to select the table they are trying to view--it's elementary I know but I have to start somewhere)
Now, I haven't changed a whole lot to the ViewTable, Tables, InsertCategory.asp files (code listed in above FORUM post so I'm not going to repost them. If needed though, please let me know.)
The code for the DeleteCategory.asp file is:
<%
Dim rs
Dim ConnectionString
Dim out
Set rs = Server.CreateObject("ADODB.Recordset")
Set ConnectionString = Server.CreateObject("ADODB.Connection")
ConnectionString.Open "Provider=SQLOLEDB.1;UID=sa;PWD=;Initial Catalog=Northwind;Data Source=localhost"
Dim strCategoryDescription
Dim strCategoryName
strCategoryDescription = Request.Form("Description")
strCategoryName = Request.Form("CategoryName")
Function DeleteCategoryTableRows()
strCategoryName = Request.Form("CategoryName")
strCategoryDescription = Request.Form("Description")
sql="DELETE FROM CATEGORIES1"
sql=sql & " WHERE CategoryName='" & strCategoryName & "'"
on error resume next
rs.open sql, ConnectionString
if err<>0 then
response.write("No Delete Permissions!")
end if
ConnectionString.close
set ConnectionString = nothing
End Function
%>
<HTML>
<BODY>
<FORM NAME = "frmDelete" ACTION="DeleteCategory.asp" METHOD = "POST">
CategoryName: <INPUT TYPE="text" NAME = "CategoryName" ><BR>
<INPUT TYPE = "Submit" VALUE = "Delete" onClick="DeleteCategory.asp"><BR>
<%= DeleteCategoryTableRows %>
Category <%= strCategoryName %>, has been deleted.<br>
</FORM>
<FORM NAME = "frmClick" ACTION="Tables.asp" METHOD = "POST">
<INPUT TYPE = "Submit" VALUE = "View Changes" onClick="Tables.asp"><BR>
</FORM>
</BODY>
</HTML>
I haven't attempted to put the Msgbox in there anywhere, well I did, but it jus screwed my program up tooo much so I just took it all out. I'm not quite sure where exactly I need to put it. However, calling the Message Box does give me a permission not allowed error (discovered that when I first tried to put it in the DELETE form on the ViewTable.asp page).
If you can help thanks a lot, until then I'll keep searching!
Quote:
quote:Originally posted by dparsons
No worries, it just comes with experience, i have only been doing this a "few" years ;] Glad it worked out for you.
--Stole this from a moderator
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
|
Toni Burgess
[email protected]