CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 4 of 5 FirstFirst 12345 LastLast
Results 46 to 60 of 63
  1. #46
    Join Date
    Jun 2013
    Posts
    102

    Re: Error code help needed

    Quote Originally Posted by dglienna View Post
    Separate the logic, and test!

    Code:
    Dim Flag as Boolean
    Flag=FALSE
    Dim Test as String
    If Test = Trim("TypeName")="" Then Flag=TRUE
    
    If Flag = TRUE then
    ' Add record only if true
    End If
    Hi There..... I've tried to do as you suggested but all l get is a blank webpage with error 500. I've copied the code below to see if you think I have made any errors ???

    Code:
    <%
    ' *** Insert new category, name and link color to the database but allows it me to enter a blank field which it shouldn't ??:
    
    Dim CategoryRS
    Set CategoryRS = Server.CreateObject("ADODB.Recordset")
    	CategoryRS.Open "SELECT * FROM Type", Connect, 2, 3
    If Not Trim("TypeName")=""Then
    	
    'Else
    '	Response.write ("You Have Not Entered A Valid Category Name")
    'End If
    'Dim Flag as Boolean
    'Flag=FALSE
    'Dim Test as String
    'If Test = Trim("TypeName")="" Then Flag=TRUE
    
    'If Flag = TRUE then
    ' Add record only if true
    CategoryRS.Addnew
    	CategoryRS("TypeName").Value=Request("TypeName")
    	CategoryRS.Update
    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>
                            <p class="textEvent">&nbsp;</p>
    all suggestions and help gratefully accepted..... Regards

  2. #47
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Error code help needed

    Looks like you COMMENTED OUT all my code. Delete the '
    IN EACH LINE at the BEGINNING of the LINE
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #48
    Join Date
    Jun 2013
    Posts
    102

    Re: Error code help needed

    Quote Originally Posted by davida1956 View Post
    Hi There..... I've tried to do as you suggested but all l get is a blank webpage with error 500. I've copied the code below to see if you think I have made any errors ???

    Code:
    <%
    ' *** Insert new category, name and link color to the database but allows it me to enter a blank field which it shouldn't ??:
    
    Dim CategoryRS
    Set CategoryRS = Server.CreateObject("ADODB.Recordset")
    	CategoryRS.Open "SELECT * FROM Type", Connect, 2, 3
    If Not Trim("TypeName")=""Then
    	
    'Else
    '	Response.write ("You Have Not Entered A Valid Category Name")
    'End If
    
    
    'Flag=FALSE
    'Dim Test as String
    'If Test = Trim("TypeName")="" Then Flag=TRUE
    
    'If Flag = TRUE then
    ' Add record only if true
    CategoryRS.Addnew
    	CategoryRS("TypeName").Value=Request("TypeName")
    	CategoryRS.Update
    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>
                            <p class="textEvent">&nbsp;</p>
    all suggestions and help gratefully accepted..... Regards
    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 :-(

  4. #49
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Error code help needed

    Not sure why I did not notice this before
    Code:
    If Not Trim("TypeName")=""Then
    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
    Always use [code][/code] tags when posting code.

  5. #50
    Join Date
    Jun 2013
    Posts
    102

    Re: Error code help needed

    Quote Originally Posted by DataMiser View Post
    Not sure why I did not notice this before
    Code:
    If Not Trim("TypeName")=""Then
    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...

    [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
    ' *** THE ERROR MESSAGE BELOW CANNOT BE SEEN***
    Response.write ("Please Enter A Valid Category Name")
    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>

    ' *** AND THE CODE MOVES TO THIS POINT ON ALL TESTS ***

    <p class="textEvent">The New Category "
    <% Response.Write Request("TypeName")
    %>
    " Has Been Added To The Database.</p>
    <p class="textEvent">&nbsp;</p></td>

    </tr>
    [CODE/]
    Last edited by davida1956; July 8th, 2013 at 06:30 PM. Reason: FORGOT CODE STATEMENT BRACKETS

  6. #51
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    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">&nbsp;</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
    Last edited by DataMiser; July 8th, 2013 at 08:32 PM.
    Always use [code][/code] tags when posting code.

  7. #52
    Join Date
    Jun 2013
    Posts
    102

    Re: Error code help needed

    Quote Originally Posted by DataMiser View Post
    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">&nbsp;</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">&nbsp;</p>
    <p class="textEvent">The category "
    <% Response.Write Request("TypeName")
    %>
    " has been added to the database.</p>
    <p class="textEvent">&nbsp;</p></td>


    [code/]

  8. #53
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    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>
    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">&nbsp;</p>
    <% Response.Write(MyMessage) %>
    
    '<p class="textEvent">The category "
    '<% Response.Write Request("TypeName")
    '%>
    '" has been added to the database.</p>
    <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.
    Last edited by DataMiser; July 9th, 2013 at 08:06 PM.
    Always use [code][/code] tags when posting code.

  9. #54
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    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.
    Always use [code][/code] tags when posting code.

  10. #55
    Join Date
    Jun 2013
    Posts
    102

    Re: Error code help needed

    Quote Originally Posted by DataMiser View Post
    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">&nbsp;</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 :-)

  11. #56
    Join Date
    Jun 2013
    Posts
    102

    Re: Error code help needed

    Quote Originally Posted by davida1956 View Post
    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">&nbsp;</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>&nbsp;</p>
    <p>
    <% Response.Write(Msg) %>
    </p>
    <p>&nbsp;</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

  12. #57
    Join Date
    Jun 2013
    Posts
    102

    Re: Error code help needed

    Got it !!!!!!!

  13. #58
    Join Date
    Jun 2013
    Posts
    102

    Re: Error code help needed

    Quote Originally Posted by davida1956 View Post
    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">&nbsp;</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!!

  14. #59
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Error code help needed

    Quote Originally Posted by davida1956 View Post
    *
    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.
    Always use [code][/code] tags when posting code.

  15. #60
    Join Date
    Jun 2013
    Posts
    102

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

Page 4 of 5 FirstFirst 12345 LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured