CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 7 of 8 FirstFirst ... 45678 LastLast
Results 91 to 105 of 114
  1. #91
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: VB Script will not remove modified data from Database

    A lot of info but mostly not needed and the part that is needed is still vague.

    The important thing is what value you are getting when the user submits the page. and is that value in the table where the color name is at. This is all that matters.

    So what value are you getting from the users submitted form and what field does that line up to Id? ColorCode?
    When that form is submitted is this the script that it is calling or are you redirecting to this script from somewhere else.

    The process is simple. The code or id or whatever gets passed to the script. the script uses that to locate the color name and then generates a display.

    In other words the user gets a form with a list of colors on his screen, he chooses one and submits the form. What values are you retrieving from the submitted form and please use a term that matches it to the DB field in the LinkColor table. What do you do from there? I assume you update the data but then what, is that part of this script? Does it call this script? Is this script from somewhere else.

    Do you know how to pass data to a script using the querystring?
    Always use [code][/code] tags when posting code.

  2. #92
    Join Date
    Jun 2013
    Posts
    102

    Re: VB Script will not remove modified data from Database

    Quote Originally Posted by DataMiser View Post
    A lot of info but mostly not needed and the part that is needed is still vague.

    The important thing is what value you are getting when the user submits the page. and is that value in the table where the color name is at. This is all that matters.

    So what value are you getting from the users submitted form and what field does that line up to Id? ColorCode?
    When that form is submitted is this the script that it is calling or are you redirecting to this script from somewhere else.

    The process is simple. The code or id or whatever gets passed to the script. the script uses that to locate the color name and then generates a display.

    In other words the user gets a form with a list of colors on his screen, he chooses one and submits the form. What values are you retrieving from the submitted form and please use a term that matches it to the DB field in the LinkColor table. What do you do from there? I assume you update the data but then what, is that part of this script? Does it call this script? Is this script from somewhere else.

    Do you know how to pass data to a script using the querystring?

    I don’t know if this helps any further but….Everything is done in the category.asp script. It is a form that the user completes It contains a text box where the user enters a new category name, selects a colour from a drop down box and then hits the add button to input data to the database. Also visible on the form is a list of existing categories, each with a delete button next to them, but that is another problem It I click on the existing category it will recover existing information from the DB and let me change the color and name of that category and this is performed in the category_edit.asp script. The category name is stored in the db under TYPE. The color name is selected from the LinkColor section which stores both the color RED and the code for it #F00 which is cross referenced in the TYPE section and assigned to the TypeName. I don't know how to pass data but think I would recognise the function. I'm not able to explain myself clearly enough am I

    There is a lot of code going on in the category.asp script but I don’t understand it and I know it is a fair chunk and a lot to ask but here it is. I would really like to know how it works and whilst I can see the comments that have been inserted, I don’t follow the code other than to know a bit performs a certain function followed by another bit.

    Code:
    <%
    ' *** Edit Operations: declare variables...
    Dim MM_editAction, MM_abortEdit, MM_editQuery, MM_recordCount
    MM_editAction = CStr(Request("URL"))
    If (Request.QueryString <> "") Then
      MM_editAction = MM_editAction & "?" & Request.QueryString
    End If
    
    ' boolean to abort record edit which is??
    MM_abortEdit = false
    
    ' query string to execute
    MM_editQuery = ""
    %>
                  
                  <%
    ' *** Delete Record: declare variables... 
    Dim MM_editTable, MM_editColumn, MM_recordId, MM_editRedirectUrl
    
    if (CStr(Request("MM_delete")) <> "" And CStr(Request("MM_recordId")) <> "") Then
    
      MM_editTable = "Type"
      MM_editColumn = "TypeId"
      MM_recordId = "" + Request.Form("MM_recordId") + ""
      MM_editRedirectUrl = "category.asp"
    
      ' append the query string to the redirect URL..... 
      If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
        If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
          MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
        Else
          MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
        End If
      End If
      
    End If
    %>
                  
                  <%
    ' *** Delete Record: construct a sql delete statement and execute it... 
    
    If (CStr(Request("MM_delete")) <> "" And CStr(Request("MM_recordId")) <> "") Then
    
      ' create the sql delete statement ... ok?
      MM_editQuery = "delete from " & MM_editTable & " where " & MM_editColumn & " = " & MM_recordId
    
      If (Not MM_abortEdit) Then
      
      	' delete links of this type
    	If(Request("MM_recordCount") <> 0) Then
    Dim evntDeleteRS
    	set evntDeleteRS = Server.CreateObject("ADODB.Recordset")
    	evntDeleteRS.Open "SELECT * FROM Events WHERE EventType = " & Request("MM_recordId"), Connect, 2, 3
    	  While (Not evntDeleteRS.EOF)
    	evntDeleteRS.Delete	
        evntDeleteRS.MoveNext
      Wend
    End If
    
        ' execute the delete which seems to work
    	Dim CategoryDeleteRS			
    	Set CategoryDeleteRS = Server.CreateObject("ADODB.Recordset")
    			CategoryDeleteRS.Open "SELECT * FROM Type WHERE TypeId =" & Request("MM_recordId"), Connect, 2, 3
    			CategoryDeleteRS.Delete	
    
        If (MM_editRedirectUrl <> "") Then
          Response.Redirect(MM_editRedirectUrl)
        End If
      End If
    
    End If
    %>
                  <%
    ' Display current categories along with the number of events in each category;
    Dim rsTypes, rsTypes_numRows
    set rsTypes = Server.CreateObject("ADODB.Recordset")
    rsTypes.Open "SELECT *, (SELECT COUNT(*) FROM Events WHERE EventType = TypeId) AS EVE_COUNT FROM Type ORDER BY TypeName ASC", Connect, 3, 3
    rsTypes_numRows = 0
    
    Dim HLooper1__numRows
    HLooper1__numRows = -2
    Dim HLooper1__index
    HLooper1__index = 0
    rsTypes_numRows = rsTypes_numRows + HLooper1__numRows
    %>
                  <table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">
                    <tr> 
                      <td height="278" align="left" valign="top"> 
                        <table width="100%" border="0" cellspacing="2" cellpadding="2">
                          <tr> 
                            <td align="left" valign="middle"><p>&nbsp;</p><form method="POST" action="category_add.asp" name="ADD">
                              <table width="412" height="111" align="center" class="textBold">
                                <tr valign="baseline"> 
                                  <td width="200" height="19" align="right" valign="middle" nowrap><p align="right" class="textEvent">Add New Category :&nbsp;&nbsp;</td>
                                  <td width="200"> <p>
                                    <input name="TypeName" type="text" class="form" value="" size="25" maxlength="25">
                                    </p></td>
                                  </tr>
                                <tr valign="baseline">
                                  <td height="16" align="right" valign="middle" nowrap>&nbsp;</td>
                                  <td>&nbsp;</td>
                                  </tr>
                                <tr valign="baseline"> 
                                  <td height="24" align="right" valign="middle" nowrap><p align="right" class="textEvent">Category Link Colour :&nbsp;&nbsp;</p></td>
                                  <td> <p>
                                    <select name="LinkColor">
                                      <%
    				  Dim LinkColorRS
    				  Set LinkColorRS = Server.CreateObject("ADODB.Recordset")
    LinkColorRS.Open "SELECT *  FROM LinkColor", Connect, 3, 3
      While (Not LinkColorRS.EOF)
        Response.Write "<option STYLE='color: " & LinkColorRS("ColorCode") & " !important' value='" & LinkColorRS("ColorCode") & "'>" & LinkColorRS("ColorName") & "</option>"
        LinkColorRS.MoveNext
    	Wend
    %>
                                      </select>
                                    </p></td>
                                  </tr>
                                <tr valign="baseline">
                                  <td height="16" align="right" nowrap>&nbsp;</td>
                                  <td>&nbsp;</td>
                                  </tr>
                                <tr valign="baseline"> 
                                  <td height="22" align="right" nowrap>&nbsp;</td>
                                  <td> <p>
                                    <input name="Add" type="submit" class="form" id="Add" value="Add">
                                    </p></td>
                                  </tr>
                                </table>
                            </form></td>
                          </tr>
                          <tr> 
                            <td height="24" align="left" valign="middle">&nbsp;</td>
                          </tr>
                          <tr> 
                            <td align="left" valign="top" class="textBold"><div align="center" class="textBold"> WARNING : Deleting a category will delete ALL of its associated events in the database.
                              <p>&nbsp;</p>
                            </div></td>
                          </tr>
                          <tr> 
                            <td height="40" align="center" valign="top"> <table width="100%">
                              <%
    Dim startrw, endrw, numberColumns, numrows
    startrw = 0
    endrw = HLooper1__index
    numberColumns = 2
    numrows = -1
    while((numrows <> 0) AND (Not rsTypes.EOF))
    	startrw = endrw + 1
    	endrw = endrw + numberColumns
     %>
                              <tr align="center" valign="top"> 
                                <%
    While ((startrw <= endrw) AND (Not rsTypes.EOF))
    %>
                                <form ACTION="<%=MM_editAction%>" METHOD="POST" name="DELETE">
                                  <td> <table width="100%" border="0" cellpadding="2" cellspacing="2">
                                    <tr align="left" valign="middle"> 
                                      <td width="22"> <input name="Submit" type="submit" class="form" value="DELETE"> 
                                        </td>
                                      <td class="textBold"><a href="category_edit.asp?iType=<%=(rsTypes.Fields.Item("TypeId").Value)%>"><strong><%=(rsTypes.Fields.Item("TypeName").Value)%></strong></a> (<%=(rsTypes.Fields.Item("EVE_COUNT").Value)%>) 
                                        </td> 
                                      <input type="hidden" name="MM_delete" value="DELETE">
                                      <input type="hidden" name="MM_recordId" value="<%= rsTypes.Fields.Item("TypeId").Value %>">
                                      <input type="hidden" name="MM_recordCount" value="<%=(rsTypes.Fields.Item("EVE_COUNT").Value)%>">
                                      
                                      </table></td>
                                  </form>
                                <%
    	startrw = startrw + 1
    	rsTypes.MoveNext()
    		Wend
    	%>
                                
                                </tr>
                              <%
     numrows=numrows-1
     Wend
    
     %>
                            </table></td>
                          </tr>
                        </table>
                      </td>
                    </tr>
                  </table>
                  <p>
                    
                    <%
    rsTypes.Close()
    %>
                    
                    
                    <
                    
                  </p>
                <p>&nbsp;</p></td>
              </tr>
            </table></td>
          </tr>
      </table>
    </div>
    <div align="center"></div>
    </html>

  3. #93
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: VB Script will not remove modified data from Database

    You keep talking about other tables and other scripts but not answering the question. I don't care what it is called in another table. I don't care what the user sees. That does not matter at all. What matters is what you have AFTER the user makes a change and how you get to the script where you are going to display something. And of course what field [in the linkcolor table] lines up with the data that is being submitted. Forget all the other tables, forget what is being done before the user submits the form what you want is after that.

    As for the script, honestly I hate scripts coded like that, they are very hard to follow mixing VBScript and HTML in such a way makes it very hard to tell what anything is especially when the indentation is all over the place like that. I can't even pull it into an editor and get it to format correctly due to the willy nilly inline VBScript.
    Always use [code][/code] tags when posting code.

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

    Re: VB Script will not remove modified data from Database

    Here is an example of a script I wrote many years ago. It does have a couple of places where it makes use of Inline VBScript and 1 place where it uses inline JavaScript but notice how much easier it is to read due to the way the script is placed into the code and formatted.
    Code:
    <%
    response.buffer=true		
    select case request.querystring("Mode")
    	case  "POST"
    		frmBody=request.form("feedbk")
    		if frmbody<>"" then
    			Set adoRS = server.CreateObject("ADODB.Recordset")
    			adoRS.Source = "select * from messages;"		
    			adoRS.ActiveConnection = session("cnprefix") & "forumsdb" & session("cnsufix")
    			adoRS.CursorType = 1
    			adoRS.LockType = 2
    			adoRS.Open
    			adors.addnew
    			adors(0)=session("UserAllias")
    			adors(1)=request.form("cat")
    			adors(2)=frmbody
    			adors(3)=now()
    			adors.update
    			adors.close
    			set adors=nothing
    			if session("RUNMODE")<>"Local" then 'asp mailer only works on web server
    				Set mailer = server.CreateObject("SMTPsvg.Mailer")
    				mailer.remotehost = "www.xyz.com"
    				mailer.fromname = "XYZ FeedBack"
    				mailer.fromaddress = "register@xyz.com"
    				mailer.addrecipient "Support", "Support@xyz.com"
    				mailer.subject = request.form("cat")
    				mailer.bodytext ="Message from ; " & session("UserAllias") & vbcrlf & frmbody
    				If mailer.sendmail Then 
    					Response.write "Mail sent <BR>"
    				else
    					Response.write "Mail not sent <BR>"
    				end if
    				Set mailer = Nothing			
    			end if				
    			response.write "<CENTER><H2>Thank you for your input.</H2>"
    			response.write "<BR><A HREF=""loggedin.asp"">Continue</A></CENTER>"							
    			response.end			
    		else			
    			response.write"<CENTER><H2>Message is blank, maybe some other time.</H2>"
    			response.write"<BR><A HREF=""loggedin.asp"">Continue</A></CENTER>"
    			response.end
    		end if			
    	Case  "Feedback"
    		headerstring="XYZ User Feed Back"
    		BdString="Please enter your comments in the space provided below."
    	Case  "Bug"
    		headerstring="XYZ Bug Report"
    		bdString ="Please describe as best you can the problem you encountered and what you were doing at the time the problem occurred. This can help us correct the problem in a timely manner."
    	Case  "Suggestion"
    		headerstring ="XYZ User Suggestions"
    		bdString="Your suggestions are welcome. Please enter your suggestion in the space provided below."
    end select
    %>
    <HTML>
    
    <HEAD>
    <TITLE></TITLE>
    <META NAME="GENERATOR" CONTENT="CutePage 2.0">
    </HEAD>
    
    <!--Begin Generic XYZ Header-->
    <BODY BGCOLOR="#FFFFFF">	
    	<H2><%=HeaderString%></H2>
    
    	<HR SIZE="3" COLOR="#0000FF">
    <!--End Generic XYZ Header-->
    
    <%=bdstring%>
    <CENTER><FORM ACTION="UFeedBK.asp?Mode=POST" METHOD="POST" TITLE="frmfeedback">
    <TEXTAREA NAME="feedbk"  ROWS="15" COLS="75">
    </TEXTAREA><BR>
    <INPUT TYPE="hidden" VALUE="<%=request.querystring("Mode")%>" NAME="cat">
    <INPUT TYPE="submit" VALUE="Submit" NAME="Submit">
    <INPUT TYPE="reset" VALUE="Reset" NAME="Reset">
    <INPUT TYPE="button" VALUE="Cancel" NAME="Cancel" onclick="javascript:history.back(1);">
    </FORM></CENTER>
    <!--Begin Generic OCC Footer-->
    	<HR SIZE="3" COLOR="#0000FF">
    	<center>
    		<FONT FACE="" SIZE="" COLOR="#0000ff">Copyright &copy; 1999-2000 <br>
    		XYZ.Com
    		<br>
    		All rights reserved</FONT>
    	</center>
    <!--End Generic XYZ Footer-->
    </BODY>
    </HTML>
    Edit: Wow Tabs step the code in a lot on here Indentation is a bit extreme

    Granted the HTML formatting leaves a bit to be desired but again this was written over 10 years ago
    Last edited by DataMiser; August 11th, 2013 at 06:42 PM.
    Always use [code][/code] tags when posting code.

  5. #95
    Join Date
    Jun 2013
    Posts
    102

    Re: VB Script will not remove modified data from Database

    Quote Originally Posted by DataMiser View Post
    Here is an example of a script I wrote many years ago. It does have a couple of places where it makes use of Inline VBScript and 1 place where it uses inline JavaScript but notice how much easier it is to read due to the way the script is placed into the code and formatted.
    Code:
    <%
    response.buffer=true		
    select case request.querystring("Mode")
    	case  "POST"
    		frmBody=request.form("feedbk")
    		if frmbody<>"" then
    			Set adoRS = server.CreateObject("ADODB.Recordset")
    			adoRS.Source = "select * from messages;"		
    			adoRS.ActiveConnection = session("cnprefix") & "forumsdb" & session("cnsufix")
    			adoRS.CursorType = 1
    			adoRS.LockType = 2
    			adoRS.Open
    			adors.addnew
    			adors(0)=session("UserAllias")
    			adors(1)=request.form("cat")
    			adors(2)=frmbody
    			adors(3)=now()
    			adors.update
    			adors.close
    			set adors=nothing
    			if session("RUNMODE")<>"Local" then 'asp mailer only works on web server
    				Set mailer = server.CreateObject("SMTPsvg.Mailer")
    				mailer.remotehost = "www.xyz.com"
    				mailer.fromname = "XYZ FeedBack"
    				mailer.fromaddress = "register@xyz.com"
    				mailer.addrecipient "Support", "Support@xyz.com"
    				mailer.subject = request.form("cat")
    				mailer.bodytext ="Message from ; " & session("UserAllias") & vbcrlf & frmbody
    				If mailer.sendmail Then 
    					Response.write "Mail sent <BR>"
    				else
    					Response.write "Mail not sent <BR>"
    				end if
    				Set mailer = Nothing			
    			end if				
    			response.write "<CENTER><H2>Thank you for your input.</H2>"
    			response.write "<BR><A HREF=""loggedin.asp"">Continue</A></CENTER>"							
    			response.end			
    		else			
    			response.write"<CENTER><H2>Message is blank, maybe some other time.</H2>"
    			response.write"<BR><A HREF=""loggedin.asp"">Continue</A></CENTER>"
    			response.end
    		end if			
    	Case  "Feedback"
    		headerstring="XYZ User Feed Back"
    		BdString="Please enter your comments in the space provided below."
    	Case  "Bug"
    		headerstring="XYZ Bug Report"
    		bdString ="Please describe as best you can the problem you encountered and what you were doing at the time the problem occurred. This can help us correct the problem in a timely manner."
    	Case  "Suggestion"
    		headerstring ="XYZ User Suggestions"
    		bdString="Your suggestions are welcome. Please enter your suggestion in the space provided below."
    end select
    %>
    <HTML>
    
    <HEAD>
    <TITLE></TITLE>
    <META NAME="GENERATOR" CONTENT="CutePage 2.0">
    </HEAD>
    
    <!--Begin Generic XYZ Header-->
    <BODY BGCOLOR="#FFFFFF">	
    	<H2><%=HeaderString%></H2>
    
    	<HR SIZE="3" COLOR="#0000FF">
    <!--End Generic XYZ Header-->
    
    <%=bdstring%>
    <CENTER><FORM ACTION="UFeedBK.asp?Mode=POST" METHOD="POST" TITLE="frmfeedback">
    <TEXTAREA NAME="feedbk"  ROWS="15" COLS="75">
    </TEXTAREA><BR>
    <INPUT TYPE="hidden" VALUE="<%=request.querystring("Mode")%>" NAME="cat">
    <INPUT TYPE="submit" VALUE="Submit" NAME="Submit">
    <INPUT TYPE="reset" VALUE="Reset" NAME="Reset">
    <INPUT TYPE="button" VALUE="Cancel" NAME="Cancel" onclick="javascript:history.back(1);">
    </FORM></CENTER>
    <!--Begin Generic OCC Footer-->
    	<HR SIZE="3" COLOR="#0000FF">
    	<center>
    		<FONT FACE="" SIZE="" COLOR="#0000ff">Copyright &copy; 1999-2000 <br>
    		XYZ.Com
    		<br>
    		All rights reserved</FONT>
    	</center>
    <!--End Generic XYZ Footer-->
    </BODY>
    </HTML>
    Edit: Wow Tabs step the code in a lot on here Indentation is a bit extreme

    Granted the HTML formatting leaves a bit to be desired but again this was written over 10 years ago


    Yours looks very neat and easy to follow. The problem I have is that the original code was written by a person who is no longer anywhere on the net and I have had to work with what I received so trying to tidy it up to look like yours will be the very last job I do, along with adding notes about code functions that I have learnt from you.... still a bit of a way to go. This issue and one more. Though I think resolving this one might well give me an insight as to how the last issue can be solved. Regards and many thanks ......DA

  6. #96
    Join Date
    Jun 2013
    Posts
    102

    Re: VB Script will not remove modified data from Database

    Quote Originally Posted by davida1956 View Post
    Yours looks very neat and easy to follow. The problem I have is that the original code was written by a person who is no longer anywhere on the net and I have had to work with what I received so trying to tidy it up to look like yours will be the very last job I do, along with adding notes about code functions that I have learnt from you.... still a bit of a way to go. This issue and one more. Though I think resolving this one might well give me an insight as to how the last issue can be solved. Regards and many thanks ......DA
    Hi DM.... not sure if you got my last post or not because I can't see it. I think displaying the darn colour with have to wait 't a little bit because I have discovered a more fundamental flaw that seems to have been there for months. The problem is that when I create a new category and assign it a colour, the colour choice is not adopted. if I then edit the category and change the colour then the database is updated. I haven't got a clue why so am going to have to go back to scratch and see if I can find out what is going on. It has got to be a problem in 1 or all of three scripts or alternatively the database itself... watch out for me..... DA

  7. #97
    Join Date
    Jun 2013
    Posts
    102

    Re: VB Script will not remove modified data from Database

    Quote Originally Posted by davida1956 View Post
    Hi DM.... not sure if you got my last post or not because I can't see it. I think displaying the darn colour with have to wait 't a little bit because I have discovered a more fundamental flaw that seems to have been there for months. The problem is that when I create a new category and assign it a colour, the colour choice is not adopted. if I then edit the category and change the colour then the database is updated. I haven't got a clue why so am going to have to go back to scratch and see if I can find out what is going on. It has got to be a problem in 1 or all of three scripts or alternatively the database itself... watch out for me..... DA

    Hi DM ...... I'm back.... short delay whilst I traced the problem and ... fixed my laptop !! I eventually rolled back the software to an earlier version in order to determine the problem. ( I take a daily back up thankfully) I found out that the problem was related to my attempts with trying to drag out information from the DB about the changed color. So that is where we left off. I can pass the session var for the changed category which you simplified for me if you recall :-) Still trying to drag the color out though. Would it help if I added another field called TypeColour into the LinkColor table in the DB so that I would have all 3 variables in the same place at the same time ColorName. .... ColorCode and TypeColour. I'm not sure if you are on vacation or not over there as most people here in the UK are as the last time I contacted you was .... ages ago :-) I look forward to your reply so hopefully I can plod on with the change given that this new idea might in fact change everything.........Regards............DA

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

    Re: VB Script will not remove modified data from Database

    At this point I am lost as to what you actually have in that table. At several points it sounded like you have the ColorCode and colorName in the same table but when I asked you went off on to something else and talking about others scripts and tables so I have no idea what you have nor what you are receiving from your form related to that table nor where that script is called from that will do the display. I asked a few questions of you that still need to be answered clearly before I can really give you any better idea than I have already.
    Always use [code][/code] tags when posting code.

  9. #99
    Join Date
    Jun 2013
    Posts
    102

    Re: VB Script will not remove modified data from Database

    Quote Originally Posted by DataMiser View Post
    At this point I am lost as to what you actually have in that table. At several points it sounded like you have the ColorCode and colorName in the same table but when I asked you went off on to something else and talking about others scripts and tables so I have no idea what you have nor what you are receiving from your form related to that table nor where that script is called from that will do the display. I asked a few questions of you that still need to be answered clearly before I can really give you any better idea than I have already.


    Hi DM.... good to be back in touch with you :-) I think I am perhaps confused by the simplicity of your solution. The problem is that I do not know how to extract a set value from the LinkColor table in the DB because that value is determined by information compiled from two tables in the DB one is called, 'LinkColor' and the other is called 'Type'.

    I can add a 'TypeName' lets call it HELP....and it gets a unique numeric identifier called 'TypeId' lets say its id is 966. The only other value is a string value called TypeColor for instance #000000. Ok... So I recall the existing Category stored in 'TypeId' and change the TypeName from 'HELP' to 'CORRECTED' the TypId stays the same. I now also change the #000000 to 00FF00. All of these functions work fine.

    The information from 'TypeColor' is written to the LinkColor('ColorCode') field and for a given value in that field there is a text name of the color. This means that CHANGED #00FF00 in the TypId has the same vale of TypeColor in the LinkColor('ColorCode") field. In this instance the text 00FF00 represents GREEN (The hex code for this green value is 00FF00 so we simply treat it as text for this purpose.

    Does this help any???
    DA

  10. #100
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: VB Script will not remove modified data from Database

    So are you saying that your linkColor table has the hex string value in it and the actual name of the color you want to display and that you have access to this hex string value from the script where you want to display it?

    If yes then that is all you need, simply do the select like I showed you and you will have the colorname that matches up with the hex string value. It really is that easy. No need to complicate things by adding more fields or trying to read more than 1 table.
    Always use [code][/code] tags when posting code.

  11. #101
    Join Date
    Jun 2013
    Posts
    102

    Re: VB Script will not remove modified data from Database

    Quote Originally Posted by DataMiser View Post
    So are you saying that your linkColor table has the hex string value in it and the actual name of the color you want to display and that you have access to this hex string value from the script where you want to display it?

    If yes then that is all you need, simply do the select like I showed you and you will have the colorname that matches up with the hex string value. It really is that easy. No need to complicate things by adding more fields or trying to read more than 1 table.

    That’s not quite right. I can change the TypeName value and the ColorName value in the category_edit.asp script which updates the database. The TypeName change is handled by this section of code. And I pass the session variable to the category_change.asp script
    Code:
    <%
    Dim TypeRS
    Dim NewName
    	Query = "SELECT * FROM Type WHERE TypeId=" & Request("TypeId")
    	Set TypeRS = Server.CreateObject("ADODB.Recordset")
    	TypeRS.Open Query, Connect, 2, 3
    	TypeRS("TypeName") = Request("TypeName")
    	TypeRS("TypeColor") = Request("LinkColor")
    	Session("NewName")=TypeRS("TypeName")
    	TypeRS.Update
    	TypeRS.Close()
    	Response.Redirect("category_change.asp")
    End If
    					%>
    The color change is a little more complex to me and I think I follow it. It’s in the same script which I show here.
    Code:
    Dim NewColor
    Dim LinkColorRS
    Set LinkColorRS = Server.CreateObject("ADODB.Recordset")
    	LinkColorRS.Open "SELECT *  FROM LinkColor", Connect, 3, 3
    While (Not LinkColorRS.EOF)
        Response.Write "<option STYLE='color: " & LinkColorRS("ColorCode") & " !important' value='" & LinkColorRS("ColorCode") & "'"
    If (CategoryRS("TypeColor") = LinkColorRS("ColorCode")) Then Response.Write "selected"
    	Response.Write">" & LinkColorRS("ColorName") & "</option>"
    	LinkColorRS.MoveNext
    Wend
    	LinkColorRS.Close()
    	CategoryRS.Close()
    %>
    This information updates the database datasheet with the new color but I cannot seen to extract that color. I don’t know where to create a session var called ‘NewColor’ or even if it is possible

    So the NewName variable is passed to the DB and modifies the ‘TypeName’ field whilst the new colour is Selected from the database(“LinkColour”) field (ColorCode) which is the (hex) text modifies the Type (‘TypeColor’) Whilst I can handle the name change. I do not know how to extract the changed colorcode.given there has been a change in the category_edit.asp. Does this help any ???

  12. #102
    Join Date
    Jun 2013
    Posts
    102

    Re: VB Script will not remove modified data from Database

    Quote Originally Posted by DataMiser View Post
    So are you saying that your linkColor table has the hex string value in it and the actual name of the color you want to display and that you have access to this hex string value from the script where you want to display it?

    If yes then that is all you need, simply do the select like I showed you and you will have the colorname that matches up with the hex string value. It really is that easy. No need to complicate things by adding more fields or trying to read more than 1 table.

    That’s not quite right. I can change the TypeName value and the ColorName value in the category_edit.asp script which updates the database. The TypeName change is handled by this section of code. And I pass the session variable to the category_change.asp script
    Code:
    <%
    Dim TypeRS
    Dim NewName
    	Query = "SELECT * FROM Type WHERE TypeId=" & Request("TypeId")
    	Set TypeRS = Server.CreateObject("ADODB.Recordset")
    	TypeRS.Open Query, Connect, 2, 3
    	TypeRS("TypeName") = Request("TypeName")
    	TypeRS("TypeColor") = Request("LinkColor")
    	Session("NewName")=TypeRS("TypeName")
    	TypeRS.Update
    	TypeRS.Close()
    	Response.Redirect("category_change.asp")
    End If
    					%>
    The color change is a little more complex to me and I think I follow it. It’s in the same script which I show here.
    Code:
    Dim NewColor
    Dim LinkColorRS
    Set LinkColorRS = Server.CreateObject("ADODB.Recordset")
    	LinkColorRS.Open "SELECT *  FROM LinkColor", Connect, 3, 3
    While (Not LinkColorRS.EOF)
        Response.Write "<option STYLE='color: " & LinkColorRS("ColorCode") & " !important' value='" & LinkColorRS("ColorCode") & "'"
    If (CategoryRS("TypeColor") = LinkColorRS("ColorCode")) Then Response.Write "selected"
    	Response.Write">" & LinkColorRS("ColorName") & "</option>"
    	LinkColorRS.MoveNext
    Wend
    	LinkColorRS.Close()
    	CategoryRS.Close()
    %>
    This information updates the database datasheet with the new color but I cannot seen to extract that color. I don’t know where to create a session var called ‘NewColor’ or even if it is possible

    So the NewName variable is passed to the DB and modifies the ‘TypeName’ field whilst the new colour is Selected from the database(“LinkColour”) field (ColorCode) which is the (hex) text modifies the Type (‘TypeColor’) Whilst I can handle the name change. I do not know how to extract the changed colorcode.given there has been a change in the category_edit.asp. Does this help any ???

  13. #103
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: VB Script will not remove modified data from Database

    To much information and no clear answer to the question at hand.

    Do you have the hex string value of the newly selected color?
    Does that Hex string value exist in the Linkcolor table?

    That is all you need.

    Please try to stay focused and not talk about other scripts and what changes and other tables.
    You want to do a simple display and to do that all you need is covered in those 2 questions but here we have 102 posts already and still not a clear answer to my questions and still no indication that you have even tried to use the select statement that I showed you abotu 50 posts back.
    Always use [code][/code] tags when posting code.

  14. #104
    Join Date
    Jun 2013
    Posts
    102

    Re: VB Script will not remove modified data from Database

    Quote Originally Posted by DataMiser View Post
    To much information and no clear answer to the question at hand.

    Do you have the hex string value of the newly selected color?
    Does that Hex string value exist in the Linkcolor table?

    That is all you need.

    Please try to stay focused and not talk about other scripts and what changes and other tables.
    You want to do a simple display and to do that all you need is covered in those 2 questions but here we have 102 posts already and still not a clear answer to my questions and still no indication that you have even tried to use the select statement that I showed you abotu 50 posts back.
    Hi DM, thanks again for your reply and indeed the patience of a saint :-) I can handle small chunks of data a lot better and try to understand to much too quick I think. I did try the select statement but couldn't get anything out of it other than the hex value of the colour instead of the text value. It wasn't the colour I had selected but instead the previous value, in effect 1 step behind all the time.

    In reply to your question, the LinkColor table only contains a list of valid colours and their text name so FF0000 = RED which is then used in the TYPE table which contains the TypeName and the TypeColour I have selected from those available, which is the hex value. I thought I had posted the bit of code from the form that appears to be doing the job??

    If you recall we started out by showing the category name change and you showed me how to set a session variable and call it elsewhere which works a treat. I went about doing things in a very long winded way which you corrected so simply. Is there anything that I should look for that will help us put this to bed�. I must admit it is frustrating me a bit. There is just one other bug to sort out and I can put it up live on our website. I�ll wait for your reply as it looks like I have a lot of other things to do this evening... Regards...DA
    Last edited by davida1956; August 19th, 2013 at 04:51 PM. Reason: random characters

  15. #105
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: VB Script will not remove modified data from Database

    You never showed where you tried the select statement so I do not know where you went wrong.

    If you have the hex value of the newly changed color that you want to display the name for and that hex value exists in the same record of the same table with the colorname as seems to be the case then as I have said a few times now it is just 1 simple select statement

    Code:
    SQLString="Select ColorName from LinkColor Where ColorCode='" & TheHexString &"'"
    You then execute that to create the RS and if the RS returns a result it will be the colorname you are looking for.

    I do not know if I am using the correct field names here as you keep bouncing around on naming conventions but ColorName would be the field that holds the literal text value Green for example and colorcode would be the field that has the HexString in it and both in the same table so whatever they are called that is what you would use. TheHexString would be the variable that holds the actual hexstring you are looking up to match the colorname to.

    If you try the select and it don;t work show what you tried rather than just saying you tried it as clearly if you tried it the right way it would work and there is no way to know what mistakes you make without knowing what you are doing and please forget about the other stuff. You should not be talkign about any other script or table as all that does it confuses the issue and makes it very hard to follow what you are talking about.
    Always use [code][/code] tags when posting code.

Page 7 of 8 FirstFirst ... 45678 LastLast

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