If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Hello and many thanks for getting back to me so quickly :-) I commented the code out because it didn't work and just returned a blank web page with error 500. I left it like that just for one of you Guru warriors to make sure that I hadn't made a stupid mistake. This is so frustrating... it seems such a simple thing in logic.... trap if the field 'TypeName' is empty or contains spaces, if so don't update the database and display the error message. I can see how your code would work but can't for the life of me see why it doesn't :-(

Re: Error code help needed

This will always be true because it is using a literal string. In other words it will never be empty. It will always be "TypeName"

You need to either assign a variable and test that or you need to use the Request("TypeName") as you have done here

Code:

CategoryRS("TypeName").Value=Request("TypeName")

Code:

If Not Trim(Request("TypeName"))=""Then

Hello and once again many thanks for your reply. I guess I am totally lost now, despite all your help and advice it still doesn't work as expected. I have added the latest information into the code and still I cannot see an error message. There is one difference however.... If I fail to assign a new category name or leave it blank the code does NOT add it to the database now. It does however still tell me that it has added the new category "" to the database. So it knows the string is empty and blocks the update. Why Can I not see the error message ?? With all the changes made I am now left with a chunk of code that looks so simple it is hard to see how it cannot do anything but work every time. I've shown it below. Do you have any other advice my friend, I'm close to giving up on it now..... :-( Thanks for staying with me...

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

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...

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">&nbsp;</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">&nbsp;</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.

Re: Error code help needed

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....

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

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....

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]

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

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....

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

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 ! :-)