Re: Error code help needed
You are still not doing it like I showed you
Code:
<p class="textEvent">The New Category "
<% Response.Write Request("TypeName")
%>
" Has Been Added To The Database.</p>
<p class="textEvent"> </p></td>
That will always get written to the screen because that is what you are telling it to do. Go back a few posts where I showed you how to do it with a variable and then you will get the correct results
Or ... you could reformat your code and place that message with in the if test. What you really need to do is think about what the code will do in each condition and place your code to do displays in such a place/way that it will only display when you want it to.
if this case you have
Code:
If Something Then
'It is ok to add a record so we add it
Else
'It is not ok to add so we don't do it
End IF
Blindly display a message that tells the user it has been added
Re: Error code help needed
Quote:
Originally Posted by
DataMiser
You are still not doing it like I showed you
Code:
<p class="textEvent">The New Category "
<% Response.Write Request("TypeName")
%>
" Has Been Added To The Database.</p>
<p class="textEvent"> </p></td>
That will always get written to the screen because that is what you are telling it to do. Go back a few posts where I showed you how to do it with a variable and then you will get the correct results
Or ... you could reformat your code and place that message with in the if test. What you really need to do is think about what the code will do in each condition and place your code to do displays in such a place/way that it will only display when you want it to.
if this case you have
Code:
If Something Then
'It is ok to add a record so we add it
Else
'It is not ok to add so we don't do it
End IF
Blindly display a message that tells the user it has been added
Hi..... I think perhaps I am a little thicker at this than I thought. I'm confused with all of the options and tests I have done, given the patience and suggestions you have made I decided the only way I can get out of the endless loop my brain seems to be in is to go back to basics and try again.
In it's simplest form this bit of code, as shown below works. If I add a valid name for the variable 'TypeName' then it updates and adds it to the database. If I don't give any input then it doesn't add anything to the database which is exactly what I want it to do. This must mean that it already is detecting the two types of input ??? Am I correct in saying that ?? If that is the case then there are only two messages that would apply "Yes that has been added" or "No your must enter a name".
I know this must sound stupid but if the code is already able to tell one state from the other am I missing something that is so simple it is invisible to me? I've tried to use the Boolean and created a new variable route but with no success other than to achieve what it already does without them. Is the problem the way I am writing an error message or perhaps not writing an error message? Has it been in the wrong place perhaps and cannot be seen as was the case with an earlier problem your brilliant suggestion of adding a hidden button fixed???
I'm at a loss and at a dead stop my friend. Modifying all of the other modules to do what I wanted seemed to be easy enough once I got my head around it and I did it in about 5 weeks but this one..... I just don't grasp it, something is wrong with my fundamentals. I understand everything you say but I just don't know how to take your suggestions and ....code them. :-( :-( Can you bear with me a little longer please... and review the code as if we had just started... you're a star...thank you so much...
[code]
<%
' *** Insert new category, name and link colour to the database:
Dim CategoryRS
Set CategoryRS = Server.CreateObject("ADODB.Recordset")
CategoryRS.Open "SELECT * FROM Type", Connect, 2, 3
If not Trim(Request("TypeName"))=""Then
CategoryRS.Addnew
CategoryRS("TypeName").Value=Request("TypeName")
CategoryRS.Update
Else
End If
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">
<tr>
<td align="left" valign="top">
<table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td align="center" valign="middle"><p class="textEvent"> </p>
<p class="textEvent">The category "
<% Response.Write Request("TypeName")
%>
" has been added to the database.</p>
<p class="textEvent"> </p></td>
[code/]
Re: Error code help needed
You are still doing the same thing
Code:
<%
' *** Insert new category, name and link colour to the database:
Dim CategoryRS
Set CategoryRS = Server.CreateObject("ADODB.Recordset")
CategoryRS.Open "SELECT * FROM Type", Connect, 2, 3
If not Trim(Request("TypeName"))=""Then
CategoryRS.Addnew
CategoryRS("TypeName").Value=Request("TypeName")
CategoryRS.Update
Else
End If
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">
<tr>
<td align="left" valign="top">
<table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td align="center" valign="middle"><p class="textEvent"> </p>
<p class="textEvent">The category "
<% Response.Write Request("TypeName")
%>
" has been added to the database.</p> ' This is going to be written to the screen no matter what because of where you are putting it and it is literal text. If you want to write it here use a variable instead.
<p class="textEvent"> </p></td>
See the code I added in Red and the code I commented out in green
Code:
<%
' *** Insert new category, name and link colour to the database:
Dim MyMessage
Dim CategoryRS
Set CategoryRS = Server.CreateObject("ADODB.Recordset")
CategoryRS.Open "SELECT * FROM Type", Connect, 2, 3
If not Trim(Request("TypeName"))=""Then
CategoryRS.Addnew
CategoryRS("TypeName").Value=Request("TypeName")
CategoryRS.Update
MyMessage="<p class=""textEvent"">The category " & Request("TypeName") & " has been added to the database.</p>"
Else
MyMessage="<p class=""textEvent"">Empty category can not be added to the database.</p>"
End If
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">
<tr>
<td align="left" valign="top">
<table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td align="center" valign="middle"><p class="textEvent"> </p>
<% Response.Write(MyMessage) %>
'<p class="textEvent">The category "
'<% Response.Write Request("TypeName")
'%>
'" has been added to the database.</p>
<p class="textEvent"> </p></td>
So the edit I show here will write one of the two messages that are set within the IF test based on the existence of data in TypeName as opposed to always writing the same thing as it was doing before.
Re: Error code help needed
A few notes related to program flow.
You really should not create the RS object and open it where you are. This will always issue a query on the database even when you are not going to do anything with it so your program will be slower than need be and use additional resources that are not needed under this condition.
You also should not pull an open ended query for the process you are doing. You should instead use a where clause that will cause the query to return no results and ideally on the primary key field. This will make it faster and use less resources.
You should also close the RS when you are done with it
so assuming that you have a auto number field named RecID and it is indexed ideally as the primary key you could write the code more like this and increase speed and reduce consumed resources.
Code:
If not Trim(Request("TypeName"))=""Then
Dim CategoryRS
Set CategoryRS = Server.CreateObject("ADODB.Recordset")
CategoryRS.Open "SELECT * FROM Type where RecId=-1", Connect, 2, 3
CategoryRS.Addnew
CategoryRS("TypeName").Value=Request("TypeName")
CategoryRS.Update
CategoryRS.Close
MyMessage="<p class=""textEvent"">The category " & Request("TypeName") & " has been added to the database.</p>"
Else
MyMessage="<p class=""textEvent"">Empty category can not be added to the database.</p>"
End If
Basically in terms of the select statement using a where clause reduces the number of records returned. In a small database on the local PC this is no big deal but in a large database on a network it can be a very big deal. Lets say that table contains 1 million records, the select you have used would return all of those records where as the one I used would return 0 records and if that field were the primary key it would do so almost instantly.
Just something to keep in mind when designing programs.
Re: Error code help needed
Quote:
Originally Posted by
DataMiser
A few notes related to program flow.
You really should not create the RS object and open it where you are. This will always issue a query on the database even when you are not going to do anything with it so your program will be slower than need be and use additional resources that are not needed under this condition.
You also should not pull an open ended query for the process you are doing. You should instead use a where clause that will cause the query to return no results and ideally on the primary key field. This will make it faster and use less resources.
You should also close the RS when you are done with it
so assuming that you have a auto number field named RecID and it is indexed ideally as the primary key you could write the code more like this and increase speed and reduce consumed resources.
Code:
If not Trim(Request("TypeName"))=""Then
Dim CategoryRS
Set CategoryRS = Server.CreateObject("ADODB.Recordset")
CategoryRS.Open "SELECT * FROM Type where RecId=-1", Connect, 2, 3
CategoryRS.Addnew
CategoryRS("TypeName").Value=Request("TypeName")
CategoryRS.Update
CategoryRS.Close
MyMessage="<p class=""textEvent"">The category " & Request("TypeName") & " has been added to the database.</p>"
Else
MyMessage="<p class=""textEvent"">Empty category can not be added to the database.</p>"
End If
Basically in terms of the select statement using a where clause reduces the number of records returned. In a small database on the local PC this is no big deal but in a large database on a network it can be a very big deal. Lets say that table contains 1 million records, the select you have used would return all of those records where as the one I used would return 0 records and if that field were the primary key it would do so almost instantly.
Just something to keep in mind when designing programs.
Hello There and many thanks for your reply again. I think it will be a bonny long time before I am able to write code!! Since being made redundant I have been looking for something worthwhile to do. I have learnt to use Dreamweaver and Flash and even written my own website. In light of everything you have said perhaps going back to school to learn how to write code is not such a bad idea after all..!!
I've noted whilst backtracking that a line of code went missing, it's the CategoryRs(TypeColor) line and I think I understand what it does so put it back in, hopefully with the correct statements which are given in the line above..CategoryRS(TypeName) in the code snippet shown below....
[code]
<%
' *** Insert new category, name and link color to the database:
If not Trim(Request("TypeName"))=""Then
Dim CategoryRS
Set CategoryRS = Server.CreateObject("ADODB.Recordset")
CategoryRS.Open "SELECT * FROM Type where EventId=-1", Connect, 2, 3
CategoryRS.Addnew
CategoryRS("TypeName").Value=Request("TypeName")
CategoryRS("TypeColor").Value=Request("LinkColor")
CategoryRS.Update
CategoryRS.Close
Else
'=== I had to comment this part of the script out or nothing would work
'===<% response.Write(<"p class=""textEvent"">The category " & Request("TypeName") & " has been added to the database.</p>"
End If
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">
<tr>
<td align="left" valign="top">
<table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td align="center" valign="middle"><p class="textEvent"> </p>
<p class="textEvent">
<%Response.write("<p class=""textEvent"">An Empty Category Can Not Be Added To The Database... Please Provide A Value !!.</p>")
%>
[code/]
I tried to run the code as it was but I simply got blank screens that could not be displayed. I've messed around with the code as I'm sure you can see. Now when I stick in an empty value it DOES tell me that I CANNOT enter it a shown above, and it doesn't update the database which is brilliant. However when I try to ADD a new Category with a valid name I get an error which points to line 60 in the code. Line 60 is where you open the database and use the RecId=-1. which I don't really follow. You are right in assuming that I have an initial field in the database that is an auto incremented numeric value called EventId which I have put in the code. The error I am gettingon screen is.....
Microsoft JET Database Engine error '80040e10'
No value given for one or more required parameters.
/calendar/admin/category_add.asp, line 60
Have I inadvertently done something right... or just created more errors??? Many thanks again :-)
Re: Error code help needed
Quote:
Originally Posted by
davida1956
Hello There and many thanks for your reply again. I think it will be a bonny long time before I am able to write code!! Since being made redundant I have been looking for something worthwhile to do. I have learnt to use Dreamweaver and Flash and even written my own website. In light of everything you have said perhaps going back to school to learn how to write code is not such a bad idea after all..!!
I've noted whilst backtracking that a line of code went missing, it's the CategoryRs(TypeColor) line and I think I understand what it does so put it back in, hopefully with the correct statements which are given in the line above..CategoryRS(TypeName) in the code snippet shown below....
[code]
<%
' *** Insert new category, name and link color to the database:
If not Trim(Request("TypeName"))=""Then
Dim CategoryRS
Set CategoryRS = Server.CreateObject("ADODB.Recordset")
CategoryRS.Open "SELECT * FROM Type where EventId=-1", Connect, 2, 3
CategoryRS.Addnew
CategoryRS("TypeName").Value=Request("TypeName")
CategoryRS("TypeColor").Value=Request("LinkColor")
CategoryRS.Update
CategoryRS.Close
Else
'=== I had to comment this part of the script out or nothing would work
'===<% response.Write(<"p class=""textEvent"">The category " & Request("TypeName") & " has been added to the database.</p>"
End If
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">
<tr>
<td align="left" valign="top">
<table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td align="center" valign="middle"><p class="textEvent"> </p>
<p class="textEvent">
<%Response.write("<p class=""textEvent"">An Empty Category Can Not Be Added To The Database... Please Provide A Value !!.</p>")
%>
[code/]
I tried to run the code as it was but I simply got blank screens that could not be displayed. I've messed around with the code as I'm sure you can see. Now when I stick in an empty value it DOES tell me that I CANNOT enter it a shown above, and it doesn't update the database which is brilliant. However when I try to ADD a new Category with a valid name I get an error which points to line 60 in the code. Line 60 is where you open the database and use the RecId=-1. which I don't really follow. You are right in assuming that I have an initial field in the database that is an auto incremented numeric value called EventId which I have put in the code. The error I am gettingon screen is.....
Microsoft JET Database Engine error '80040e10'
No value given for one or more required parameters.
/calendar/admin/category_add.asp, line 60
Have I inadvertently done something right... or just created more errors??? Many thanks again :-)
****** GOT IT AT LONG LAST !!!! I took your advice on a couple of things and just sort of put it altogether and it works !!!!! Would you care to just give the semantics of my bodge please...
[code]
Dim Msg
Dim CategoryRS
Set CategoryRS = Server.CreateObject("ADODB.Recordset")
CategoryRS.Open "SELECT * FROM Type", Connect, 2, 3
If not Trim(Request("TypeName"))=""Then
CategoryRS.Addnew
CategoryRS("TypeName").Value=Request("TypeName")
CategoryRS("TypeColor").Value=Request("LinkColor")
CategoryRS.Update
CategoryRS.Close
Msg="<p class=""textEvent"">The category " & Request("TypeName") & " has been added to the database.</p>"
Else
Msg="<p class=""textEvent"">Empty category can not be added to the database.</p>"
End If
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">
<tr>
<td align="left" valign="top">
<table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td align="center" valign="middle"><p> </p>
<p>
<% Response.Write(Msg) %>
</p>
<p> </p>
[code/]
Could I ask a few more questions before I ask you how to sing your praises to the highest degree on this forum....I honestly thought 3 years out of work had turned my brain to grey mush !! You're a real star my friend !! :-) :0
Re: Error code help needed
Re: Error code help needed
Quote:
Originally Posted by
davida1956
hello there and many thanks for your reply again. I think it will be a bonny long time before i am able to write code!! Since being made redundant i have been looking for something worthwhile to do. I have learnt to use dreamweaver and flash and even written my own website. In light of everything you have said perhaps going back to school to learn how to write code is not such a bad idea after all..!!
I've noted whilst backtracking that a line of code went missing, it's the categoryrs(typecolor) line and i think i understand what it does so put it back in, hopefully with the correct statements which are given in the line above..categoryrs(typename) in the code snippet shown below....
[code]
<%
' *** insert new category, name and link color to the database:
If not trim(request("typename"))=""then
dim categoryrs
set categoryrs = server.createobject("adodb.recordset")
categoryrs.open "select * from type where eventid=-1", connect, 2, 3
categoryrs.addnew
categoryrs("typename").value=request("typename")
categoryrs("typecolor").value=request("linkcolor")
categoryrs.update
categoryrs.close
else
'=== i had to comment this part of the script out or nothing would work
'===<% response.write(<"p class=""textevent"">the category " & request("typename") & " has been added to the database.</p>"
end if
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">
<tr>
<td align="left" valign="top">
<table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td align="center" valign="middle"><p class="textevent"> </p>
<p class="textevent">
<%response.write("<p class=""textevent"">an empty category can not be added to the database... Please provide a value !!.</p>")
%>
[code/]
i tried to run the code as it was but i simply got blank screens that could not be displayed. I've messed around with the code as i'm sure you can see. Now when i stick in an empty value it does tell me that i cannot enter it a shown above, and it doesn't update the database which is brilliant. However when i try to add a new category with a valid name i get an error which points to line 60 in the code. Line 60 is where you open the database and use the recid=-1. Which i don't really follow. You are right in assuming that i have an initial field in the database that is an auto incremented numeric value called eventid which i have put in the code. The error i am gettingon screen is.....
Microsoft jet database engine error '80040e10'
no value given for one or more required parameters.
/calendar/admin/category_add.asp, line 60
have i inadvertently done something right... Or just created more errors??? Many thanks again :-)
got it !!!!!!! I seriously thought 3 years of unemployment had turned my brain to grey mush and that I couldn't follow simple logical instructions!! You my friend are a STAR!!
Re: Error code help needed
Quote:
Originally Posted by
davida1956
*
Could I ask a few more questions before I ask you how to sing your praises to the highest degree on this forum....I honestly thought 3 years out of work had turned my brain to grey mush !! You're a real star my friend !! :-) :0
There is a little star icon at the bottom left of each post, give that a click on one of the posts you found helpful. This adds a small amount to the rating of the person who posted the info.
Re: Error code help needed
Hi DM... I've followed the advice as to how I can best say thank you and clicked on the star to leave my comments. I hope others get to see what I wrote. I can't thank you enough for your patience with a total newbie who only has a slight grasp on this new field of engineering. You've taught me quite a few things but left me with a million more things to ask.
I now recognise other areas of the code that need to looked at for the same reason, the code is there but it doesn't do what the comments say it should. I have things I want to improve on but I think I will be looking at things with a different perspective from now on. I don't know if I am allowed to discuss more than one thread or if I have to post another thread for another problem in the same program. Do you have any words of wisdom for me ?? :-) For anybody out there who comes across this thread.... Those who say forums are a waste of time..... You couldn't be further from the truth if you tried!!! look forward to your reply and again thanks a million for your patience and help. Perhaps a small simple problem to somebody with your skills but to a novice... it was a task and a half ! :-)
Re: Error code help needed
I've just figured out that opening and dealing with one thread at a time is a much better way of showing the world that as a problem solver is well equipped. It is much more representative of your skills to deal with multiple threads and not multiple questions in a single thread. So....... I will go back to my code.... do as much as I can, referring back to this thread for examples, and then if I get stuck again, post a new thread and hope that you pick up an interest. Thank you again for staying with me. Perhaps one day I will be able to give back something I have learnt here... to a fresh newbie :-)...........Regards DA.
Re: Error code help needed
or upgrade to VS and let it handle threads for you
Re: Error code help needed
Quote:
Originally Posted by
dglienna
or upgrade to VS and let it handle threads for you
??
I do believe he is talking about threads on the message board rather than threading in his programs.
Quote:
I've just figured out that opening and dealing with one thread at a time is a much better way of showing the world that as a problem solver is well equipped.
Yes much better to start a new thread for a new issue.
You should also mark your thread resolved once you have the answer you need.
You can do this by clicking on the thread tools menu link at the top of first post and selecting the resolved option