-
[RESOLVED] VB Script will not remove modified data from Database
Hello to all members. I'm trying to find some more help on another problem I have found in my script. My last post was resolved with the patience of DataMiser who guided me through the unfamiliar software code. I'm by no means a professional and still learning the basics. Basically I have a series of server side .asp scripts most of which work brilliantly now, but I have one problem that I can't figure out.
An explanation of what it does may be a good place to start. One script takes the information from a screen form and enters it into an Access DB and this works great. I have another form which allows me to edit that form and change any of the fields shown on the approved form. Every field works great with the exception of one. This field contains up to 14 dates all correctly entered into the DB. If I change a date on the form it works, if I add another date, it works and the DB is updated. If I try to delete one of the entries however it cannot perform the task and simply leaves the data intact within the database.
I think I have pinned the problem down to a small part of the form and can post the data...... Is there anybody out there that would like to take up the challenge to teach me a few more bits of programming ? I've tried everything that I learnt from DataMiser but the gems I learnt from him can't be used here as a little sql knowledge, which I don't have is needed. This again is a bit out of my league and hopefully there will be a patient teacher out there.... Can anybody help please. ???? I can
-
Re: VB Script will not remove modified data from Database
Quote:
If I try to delete one of the entries however it cannot perform the task and simply leaves the data intact within the database.
I'm not quite sure what you mean by this. Is it a string field that has a list of dates in it? What code are you using to try and remove one of the entries from the string?
-
Re: VB Script will not remove modified data from Database
Quote:
Originally Posted by
DataMiser
I'm not quite sure what you mean by this. Is it a string field that has a list of dates in it? What code are you using to try and remove one of the entries from the string?
Hi my friend, really nice of you to get back to me, I was hoping you would pick it up as you're pretty familiar with what I am trying to do. The information is in a series of 14 fields each with its own descriptor... EventDated1 ..... EventDated14 in Access db So it's not string. As for the code I am looking at two possibilities. 1 is in a edit.asp script file and the other is in a submit.asp script file not sure which one might be the problem yet.
This is the code that actually adds the data and it works well. You might recognise some of the field names
Code:
DATE 1 :
</td>
<td valign="middle" bgcolor="#000"><input name="EventDated" type="text" class="form" id="EventDated" value="<%=(rsEdit.Fields.Item("EventDated").Value)%>" size="20" maxlength="60">`</td>
When I want to change data and lets say add another date then I can do so manually on the form by using the correct NUMERIC TEXT format because that is how it is displayed at this point. This bit works fine. If I want to change information and remove one of the dates (which now appear as numeric text) then you simply backspace, highlight and delete etc and then hit the submit button which should then read the data and re-write the information into the DB under it's unique identifier which we called EventId. This is the part that doesn't work. When I hit the same submit button this is the code it calls on
Code:
<input name="save" type="submit" class="form" id="submit2" onClick="MM_validateForm('EventName','','R','EVE_URL','','R','EventDescription','','R');return document.MM_returnValue" value="Save Changes">
does that make any sense to you? I would also love to understand what the digits are when you connect to the DB...... eg ...... connect 2, 3... are they field numbers ??
Thanks for the help again... Wish I could buy you a drink :-):thumb: I look forward to learning a bit about this type of routine as well because there are other things I could perhaps apply it to. By the way, I did use what you taught me to repair another similar problem in the code :)
-
Re: VB Script will not remove modified data from Database
Doesn't look like the code that would update the database is there.
I see code that populates the page from the database and some client side web stuff but not the server side part that would apply whatever changes you made.
-
Re: VB Script will not remove modified data from Database
Quote:
I would also love to understand what the digits are when you connect to the DB...... eg ...... connect 2, 3... are they field numbers ??
Maybe you mean the next:
Code:
Opens a cursor on a Recordset object.
Syntax :
recordset.Open Source, ActiveConnection, CursorType, LockType, Options
Parameters :
Source
Optional. A Variant that evaluates to a valid Command object, an SQL statement, a table name, a stored procedure call, a URL, or the name of a file or Stream object containing a persistently stored Recordset.
ActiveConnection
Optional. Either a Variant that evaluates to a valid Connection object variable name, or a String that contains ConnectionString parameters.
CursorType
Optional. A CursorTypeEnum value that determines the type of cursor that the provider should use when opening the Recordset. The default value is adOpenForwardOnly.
CursorTypeEnum: Specifies the type of cursor used in a Recordset object.
adOpenDynamic 2 Uses a dynamic cursor. Additions, changes, and deletions by other users are visible, and all types of movement through the Recordset are allowed, except for bookmarks, if the provider doesn't support them.
adOpenForwardOnly 0 Default. Uses a forward-only cursor. Identical to a static cursor, except that you can only scroll forward through records. This improves performance when you need to make only one pass through a Recordset.
adOpenKeyset 1 Uses a keyset cursor. Like a dynamic cursor, except that you can't see records that other users add, although records that other users delete are inaccessible from your Recordset. Data changes by other users are still visible.
adOpenStatic 3 Uses a static cursor, which is a static copy of a set of records that you can use to find data or generate reports. Additions, changes, or deletions by other users are not visible.
adOpenUnspecified -1 Does not specify the type of cursor.
LockType
Optional. A LockTypeEnum value that determines what type of locking (concurrency) the provider should use when opening the Recordset. The default value is adLockReadOnly.
LockTypeEnum: Specifies the type of lock placed on records during editing.
adLockBatchOptimistic 4 Indicates optimistic batch updates. Required for batch update mode.
adLockOptimistic 3 Indicates optimistic locking, record by record. The provider uses optimistic locking, locking records only when you call the Update method.
adLockPessimistic 2 Indicates pessimistic locking, record by record. The provider does what is necessary to ensure successful editing of the records, usually by locking records at the data source immediately after editing.
adLockReadOnly 1 Indicates read-only records. You cannot alter the data.
adLockUnspecified -1 Does not specify a type of lock. For clones, the clone is created with the same lock type as the original.
Options
Optional. A Long value that indicates how the provider should evaluate the Source argument if it represents something other than a Command object, or that the Recordset should be restored from a file where it was previously saved. Can be one or more CommandTypeEnum or ExecuteOptionEnum values, which can be combined with a bitwise OR operator.
-
Re: VB Script will not remove modified data from Database
Quote:
Originally Posted by
jggtz
Maybe you mean the next:
Code:
Opens a cursor on a Recordset object.
Syntax :
recordset.Open Source, ActiveConnection, CursorType, LockType, Options
Parameters :
Source
Optional. A Variant that evaluates to a valid Command object, an SQL statement, a table name, a stored procedure call, a URL, or the name of a file or Stream object containing a persistently stored Recordset.
ActiveConnection
Optional. Either a Variant that evaluates to a valid Connection object variable name, or a String that contains ConnectionString parameters.
CursorType
Optional. A CursorTypeEnum value that determines the type of cursor that the provider should use when opening the Recordset. The default value is adOpenForwardOnly.
CursorTypeEnum: Specifies the type of cursor used in a Recordset object.
adOpenDynamic 2 Uses a dynamic cursor. Additions, changes, and deletions by other users are visible, and all types of movement through the Recordset are allowed, except for bookmarks, if the provider doesn't support them.
adOpenForwardOnly 0 Default. Uses a forward-only cursor. Identical to a static cursor, except that you can only scroll forward through records. This improves performance when you need to make only one pass through a Recordset.
adOpenKeyset 1 Uses a keyset cursor. Like a dynamic cursor, except that you can't see records that other users add, although records that other users delete are inaccessible from your Recordset. Data changes by other users are still visible.
adOpenStatic 3 Uses a static cursor, which is a static copy of a set of records that you can use to find data or generate reports. Additions, changes, or deletions by other users are not visible.
adOpenUnspecified -1 Does not specify the type of cursor.
LockType
Optional. A LockTypeEnum value that determines what type of locking (concurrency) the provider should use when opening the Recordset. The default value is adLockReadOnly.
LockTypeEnum: Specifies the type of lock placed on records during editing.
adLockBatchOptimistic 4 Indicates optimistic batch updates. Required for batch update mode.
adLockOptimistic 3 Indicates optimistic locking, record by record. The provider uses optimistic locking, locking records only when you call the Update method.
adLockPessimistic 2 Indicates pessimistic locking, record by record. The provider does what is necessary to ensure successful editing of the records, usually by locking records at the data source immediately after editing.
adLockReadOnly 1 Indicates read-only records. You cannot alter the data.
adLockUnspecified -1 Does not specify a type of lock. For clones, the clone is created with the same lock type as the original.
Options
Optional. A Long value that indicates how the provider should evaluate the Source argument if it represents something other than a Command object, or that the Recordset should be restored from a file where it was previously saved. Can be one or more CommandTypeEnum or ExecuteOptionEnum values, which can be combined with a bitwise OR operator.
Hi JG ??? Phew .... that is going to take some digesting !!!! CUT.... PASTE.....GOOGLE :-) to say the least !! Not sure where that code is now as I though that was it, so I will have to trawl through these 3 scripts to find out which might do the update. You are of course quite right in saying that the information passed to those fields populate the DB. I just need to find out what recovers the information.. which I think will be in the edit.asp script, from the DB and what code appends the new information back to the DB... sounds easy enough huh :-) I had best begin tonight then !!! thanks again my friend......
DA :wave::thumb:
-
Re: VB Script will not remove modified data from Database
Quote:
Originally Posted by
davida1956
Hi JG ??? Phew .... that is going to take some digesting !!!! CUT.... PASTE.....GOOGLE :-) to say the least !! Not sure where that code is now as I though that was it, so I will have to trawl through these 3 scripts to find out which might do the update. You are of course quite right in saying that the information passed to those fields populate the DB. I just need to find out what recovers the information.. which I think will be in the edit.asp script, from the DB and what code appends the new information back to the DB... sounds easy enough huh :-) I had best begin tonight then !!! thanks again my friend......
DA :wave::thumb:
The code above looks as if it is calling for another routine called MM_validateForm .. I think. This is also on the page but there is a lot of it that simply doesn't add up as it checks for errors in email address for instance... None of the calendar features include an email function.... here is the code... can you explain it simply for me please.
Code:
<!--
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
}
//-->
There is another chunks of code with comments such as create sql query...... I expanded it from a 2 day event to a 14 day event here and in many other parts of the program....
Code:
<%
' *** Update Record: construct a sql update statement and execute it
If (CStr(Request("MM_update")) <> "" And CStr(Request("MM_recordId")) <> "") Then
' create the sql update statement
Dim Query, EventsRS
Query = "SELECT * FROM Events WHERE EventId=" & Request("MM_recordId")
Set EventsRS = Server.CreateObject("ADODB.Recordset")
EventsRS.Open Query, Connect, 2, 3
' This is part of the 14 day event modification.
EventsRS("EventType") = Request("EventType")
EventsRS("EventName") = Request("EventName")
EventsRS("EventDated") = Request("EventDated")
If IsDate(Request("EventDated_2")) Then EventsRS("EventDated_2") = Request("EventDated_2")
If IsDate(Request("EventDated_3")) Then EventsRS("EventDated_3") = Request("EventDated_3")
If IsDate(Request("EventDated_4")) Then EventsRS("EventDated_4") = Request("EventDated_4")
If IsDate(Request("EventDated_5")) Then EventsRS("EventDated_5") = Request("EventDated_5")
If IsDate(Request("EventDated_6")) Then EventsRS("EventDated_6") = Request("EventDated_6")
If IsDate(Request("EventDated_7")) Then EventsRS("EventDated_7") = Request("EventDated_7")
If IsDate(Request("EventDated_8")) Then EventsRS("EventDated_8") = Request("EventDated_8")
If IsDate(Request("EventDated_9")) Then EventsRS("EventDated_9") = Request("EventDated_9")
If IsDate(Request("EventDated_10")) Then EventsRS("EventDated_10") = Request("EventDated_10")
If IsDate(Request("EventDated_11")) Then EventsRS("EventDated_11") = Request("EventDated_11")
If IsDate(Request("EventDated_12")) Then EventsRS("EventDated_12") = Request("EventDated_12")
If IsDate(Request("EventDated_13")) Then EventsRS("EventDated_13") = Request("EventDated_13")
If IsDate(Request("EventDated_14")) Then EventsRS("EventDated_14") = Request("EventDated_14")
EventsRS("EventLocation") = Request("EventLocation")
EventsRS("EventDescription") = Request("EventDescription")
EventsRS("EventApproved") = Request("EventApproved")
EventsRS.Update
EventsRS.Close()
Response.Redirect("events.asp")
End If
%>
am I getting closer to the code that has the problem? I think I'll do a compare. All the way down the upgrade route I have made daily backups. Perhaps I should rewind files in the 'admin' folder because I'm positive the fault is in one of 3 files... it's just the where bit ... that is hard :-) Look forward to hearing back.... Regards....... DA
:thumb:
-
Re: VB Script will not remove modified data from Database
The second piece of code is the likely culprit and the issue would appear to be that you are only updating the field if there is a valid date coming from the form for that field. So if you omit one of the dates the value that is already int he database will be retained as your code will not tell it to update that field due to it not receiving a valid date for it. given the existing code a simple fix would be to add an else portion to those if statements that sets the field to null if no valid date is given.
btw I find it much easier to work with ASP in VB.Net than in VB6. VB.Net actually allows you to run the code in debug mode and that gives you access to several tools for testing and locating issues with the code.
-
Re: VB Script will not remove modified data from Database
Quote:
Originally Posted by
davida1956
The code above looks as if it is calling for another routine called MM_validateForm .. I think. This is also on the page but there is a lot of it that simply doesn't add up as it checks for errors in email address for instance... None of the calendar features include an email function.... here is the code... can you explain it simply for me please.
Code:
<!--
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
}
//-->
There is another chunks of code with comments such as create sql query...... I expanded it from a 2 day event to a 14 day event here and in many other parts of the program....
Code:
<%
' *** Update Record: construct a sql update statement and execute it
If (CStr(Request("MM_update")) <> "" And CStr(Request("MM_recordId")) <> "") Then
' create the sql update statement
Dim Query, EventsRS
Query = "SELECT * FROM Events WHERE EventId=" & Request("MM_recordId")
Set EventsRS = Server.CreateObject("ADODB.Recordset")
EventsRS.Open Query, Connect, 2, 3
' This is part of the 14 day event modification.
EventsRS("EventType") = Request("EventType")
EventsRS("EventName") = Request("EventName")
EventsRS("EventDated") = Request("EventDated")
If IsDate(Request("EventDated_2")) Then EventsRS("EventDated_2") = Request("EventDated_2")
If IsDate(Request("EventDated_3")) Then EventsRS("EventDated_3") = Request("EventDated_3")
If IsDate(Request("EventDated_4")) Then EventsRS("EventDated_4") = Request("EventDated_4")
If IsDate(Request("EventDated_5")) Then EventsRS("EventDated_5") = Request("EventDated_5")
If IsDate(Request("EventDated_6")) Then EventsRS("EventDated_6") = Request("EventDated_6")
If IsDate(Request("EventDated_7")) Then EventsRS("EventDated_7") = Request("EventDated_7")
If IsDate(Request("EventDated_8")) Then EventsRS("EventDated_8") = Request("EventDated_8")
If IsDate(Request("EventDated_9")) Then EventsRS("EventDated_9") = Request("EventDated_9")
If IsDate(Request("EventDated_10")) Then EventsRS("EventDated_10") = Request("EventDated_10")
If IsDate(Request("EventDated_11")) Then EventsRS("EventDated_11") = Request("EventDated_11")
If IsDate(Request("EventDated_12")) Then EventsRS("EventDated_12") = Request("EventDated_12")
If IsDate(Request("EventDated_13")) Then EventsRS("EventDated_13") = Request("EventDated_13")
If IsDate(Request("EventDated_14")) Then EventsRS("EventDated_14") = Request("EventDated_14")
EventsRS("EventLocation") = Request("EventLocation")
EventsRS("EventDescription") = Request("EventDescription")
EventsRS("EventApproved") = Request("EventApproved")
EventsRS.Update
EventsRS.Close()
Response.Redirect("events.asp")
End If
%>
am I getting closer to the code that has the problem? I think I'll do a compare. All the way down the upgrade route I have made daily backups. Perhaps I should rewind files in the 'admin' folder because I'm positive the fault is in one of 3 files... it's just the where bit ... that is hard :-) Look forward to hearing back.... Regards....... DA
:thumb:
Hi and once again thanks for your support and suggestions. At least I seem to be looking in the right part of code much faster now which reflects what you have taught me recently. Would I be correct in assuming that each variable in the database will need to be catered for in the 'Else' statement or is there a 'catch for all' option. Would the code I insert be prior to the DB update and if so should it look like this
Code:
If IsDate(Request("EventDated_13")) Then EventsRS("EventDated_13") = Request("EventDated_13")
If IsDate(Request("EventDated_14")) Then EventsRS("EventDated_14") = Request("EventDated_14")
EventsRS("EventLocation") = Request("EventLocation")
EventsRS("EventDescription") = Request("EventDescription")
EventsRS("EventApproved") = Request("EventApproved")
'Else
' EventRS("EventType") = Null
' EventRs("EventName") = Null
' EventRS("EventDated") = Null
' EventRS("EventLocation") = Null
' EventRS("EventDescription")= Null
' EventRS("EventApproveved")= Null
EventsRS.Update
EventsRS.Close()
Response.Redirect("events.asp")
End If
I have commented it out in case there is a better alternative but in the meantime will test it. perhaps I should have done that first but I need to go out this evening and with luck, if I have made a mistake there will be something here for me to digest and implement later :-) Thanks again :thumb::wave:
-
Re: VB Script will not remove modified data from Database
Quote:
Originally Posted by
davida1956
Would I be correct in assuming that each variable in the database will need to be catered for in the 'Else' statement or is there a 'catch for all' option. Would the code I insert be prior to the DB update and if so should it look like this
No, based on what you have said so far you only want to set the date field to null in the case where there is not a valid date.
Code:
If IsDate(Request("EventDated_2")) Then EventsRS("EventDated_2") = Request("EventDated_2") Else EventsRS("EventDated_2") = null
If IsDate(Request("EventDated_3")) Then EventsRS("EventDated_3") = Request("EventDated_3") Else EventsRS("EventDated_3") = null
' and so on
-
Re: VB Script will not remove modified data from Database
Quote:
Originally Posted by
DataMiser
No, based on what you have said so far you only want to set the date field to null in the case where there is not a valid date.
Code:
If IsDate(Request("EventDated_2")) Then EventsRS("EventDated_2") = Request("EventDated_2") Else EventsRS("EventDated_2") = null
If IsDate(Request("EventDated_3")) Then EventsRS("EventDated_3") = Request("EventDated_3") Else EventsRS("EventDated_3") = null
' and so on
Hiya :) Yep that makes perfect sense because all the other fields must have an entry in them and that bit of code works well. I guess if I wanted to reset the whole record then I would use the other method. I have that section of code in several places within the whole program so should be able to integrate the whole thing now. I am a little more confident now armed wit a little knowledge, but a little can also be dangerous. :blush: perhaps getting a bit better at identifying what code seems to do within the function. I am interested by your last comment about working with code in VB.NET. Is there anything that I can do, within my current level of skill, to convert or provide code in that format. Totally new to me and have never heard of VB.NET..... till now :-) I would also be interested if you could perhaps explain the first bit of code I posted with error checking for things like email. Does the code have capability that I am not aware of? It was free GNU software that some great guy out there that gave a great deal of time and effort to pass on a useful product to the community. I tried to contact him originally but never received a reply and the email bounced so I guess he is no longer there.
I'll implement and test the code and all other functions tonight and let you know how it goes. Can I ask how you got involved with writing code, I guess helping others gives you a sense of satisfaction I know I get the same feeling of a job well done when I use my own field of expertise to help others. It must be second nature to you by now :-) Thanks again :thumb::)
-
Re: VB Script will not remove modified data from Database
VB6 was released in 1998 ASP came about also in the later 90s. After VB6 VB.Net was released so far there have been several releases including 2003,2005,2008,2010,2012 they even give a version for free called VB Express. The newer VB environment is designed to create ASP.Net code which is expanded over the basic ASP stuff and you can work with it in the designer and run tests and such. Is a much easier tool to work with when doing web related stuff.
The other bit of code you posted is Java Script which I am far from an expert on, you may have better results posting that piece of code and asking questions in the Client side scripting area here http://forums.codeguru.com/forumdisp...ng-Client-Side
I started coding a long time ago because I thought it was interesting and found I liked it quite a lot. I originally had an idea for a game that I wanted to create but it was a very bold idea that never really panned out. Still I learned tons while doing it and then wrote a different game that was a bit simpler which i was able to sell a few hundred copies of. Eventually I got a job for a software developer and then went off on my own.
-
Re: VB Script will not remove modified data from Database
Quote:
Originally Posted by
DataMiser
VB6 was released in 1998 ASP came about also in the later 90s. After VB6 VB.Net was released so far there have been several releases including 2003,2005,2008,2010,2012 they even give a version for free called VB Express. The newer VB environment is designed to create ASP.Net code which is expanded over the basic ASP stuff and you can work with it in the designer and run tests and such. Is a much easier tool to work with when doing web related stuff.
The other bit of code you posted is Java Script which I am far from an expert on, you may have better results posting that piece of code and asking questions in the Client side scripting area here
http://forums.codeguru.com/forumdisp...ng-Client-Side
I started coding a long time ago because I thought it was interesting and found I liked it quite a lot. I originally had an idea for a game that I wanted to create but it was a very bold idea that never really panned out. Still I learned tons while doing it and then wrote a different game that was a bit simpler which i was able to sell a few hundred copies of. Eventually I got a job for a software developer and then went off on my own.
I guess that the software is backwards compatible and that I should be able to import all the current code into the toolset.. or is that not the case. I work with the adobe toolset.... Dreamwever etc. And have developed a few websites, two of them for myself and 2 others for people I knew who had their own business but I am by no means a professional !! I'll join the suggested forum and ask some questions. I'm getting quite enthusiastic now as other tweaks I am making to the code are going well. I think I put that down to your own enthusiasm my friend :-)
I tried my hand at writing software many, many years ago with the Open University who were doing a full course in Pascal. I don't think I was ready then and didn't do well at all. I went on with my Hardware instincts which is or was my livelihood. I got as far as being a Dell Certified Engineer and can strip and repair (to component level unlike board swaps of today) anything from a simple laptop to clustered servers. Obviously I needed to get my Microsoft Certificate to compliment the years of experience in the field. Installing software and understanding what it does and should be capable of doing is part of the job. Writing the stuff is much like chalk and cheese, two extremes of the same field, writing is the really hard stuff !! I'm very used to the TechNet forum and have developed alongside it I guess and I'm also used to talking directly to the backline techies in Dell if I ever had a problem that needed bouncing round a few heads before implementing it.
Since I was made redundant a few years ago I have been looking for something to keep my grey matter going. The trouble is that with coding I can seem to find a place to start and everything needs to have previous knowledge before trying the next part. Then there is a multitude of languages to try.... I very much admire what you have achieved and tried to do the same for myself. The IT sector here though, especially with the recession is almost impossible to get into. customers are happy to keep who they have and don't want to buy or commission new equipment because ... they may go bust. At 56 I'm sorry to say that I feel a bit like having been dumped on the scrap heap yet I feel I have a lot to offer, especially to young engineer just setting out. Years of experience which would for instance allow me to put a circuit together that will do a simple job like a timer circuit costing about 50 pence rather than trawling through catalogues which will inevitable have a chip that has that function built in that you would then have to develop and so on. In business time is money and speed often clinches the deal. I'm sure you have come across that though :-) Nice to know a bit about you.
-
Re: VB Script will not remove modified data from Database
Quote:
Originally Posted by
davida1956
I guess that the software is backwards compatible and that I should be able to import all the current code into the toolset.. or is that not the case. I work with the adobe toolset.... Dreamwever etc. And have developed a few websites, two of them for myself and 2 others for people I knew who had their own business but I am by no means a professional !! I'll join the suggested forum and ask some questions. I'm getting quite enthusiastic now as other tweaks I am making to the code are going well. I think I put that down to your own enthusiasm my friend :-)
I tried my hand at writing software many, many years ago with the Open University who were doing a full course in Pascal. I don't think I was ready then and didn't do well at all. I went on with my Hardware instincts which is or was my livelihood. I got as far as being a Dell Certified Engineer and can strip and repair (to component level unlike board swaps of today) anything from a simple laptop to clustered servers. Obviously I needed to get my Microsoft Certificate to compliment the years of experience in the field. Installing software and understanding what it does and should be capable of doing is part of the job. Writing the stuff is much like chalk and cheese, two extremes of the same field, writing is the really hard stuff !! I'm very used to the TechNet forum and have developed alongside it I guess and I'm also used to talking directly to the backline techies in Dell if I ever had a problem that needed bouncing round a few heads before implementing it.
Since I was made redundant a few years ago I have been looking for something to keep my grey matter going. The trouble is that with coding I can seem to find a place to start and everything needs to have previous knowledge before trying the next part. Then there is a multitude of languages to try.... I very much admire what you have achieved and tried to do the same for myself. The IT sector here though, especially with the recession is almost impossible to get into. customers are happy to keep who they have and don't want to buy or commission new equipment because ... they may go bust. At 56 I'm sorry to say that I feel a bit like having been dumped on the scrap heap yet I feel I have a lot to offer, especially to young engineer just setting out. Years of experience which would for instance allow me to put a circuit together that will do a simple job like a timer circuit costing about 50 pence rather than trawling through catalogues which will inevitable have a chip that has that function built in that you would then have to develop and so on. In business time is money and speed often clinches the deal. I'm sure you have come across that though :-) Nice to know a bit about you.
I'm not sure if my previous post regarding an asp issue and a database access question got to you as I can't see them. Our posts crossed at the same time and I pressed the send at the same time as your arrived :-) Can you let me know please my friend :-) Thanks
-
Re: VB Script will not remove modified data from Database
Not sure which question you are talking about??
-
Re: VB Script will not remove modified data from Database
Quote:
Originally Posted by
DataMiser
Not sure which question you are talking about??
Hiya .... I was wanting to extract a specific field from the database in this software. The other question was on how to implement a new page I have developed for indication a record has been deleted but that is another story :-)
-
Re: VB Script will not remove modified data from Database
You mean as in "Select FieldName From Table" ?
-
Re: VB Script will not remove modified data from Database
Quote:
Originally Posted by
DataMiser
You mean as in "Select FieldName From Table" ?
Hello my friend. I thought it was a simple as that but I have tried to extract a specific field attribute. Perhaps I should explain, I am sure you will recognise much of what I write but writing it down also reinforces my belief that I am learning and understanding what I am doing, that and I have still got a lot to learn, I know you or another member of this site will take the time and effort will put me on the right track again if I fall off. :-) S ooooo I have an Access DB which has four parts to it.... One Called ADMIN Which obviously contains a 2 field array for username and password. This is called for before going any further. Another Section is called 'Events' which contains multiple fields where all dates are written to, along with the EventDate, EventId, EventType, EventLocation and EventDescription. All of these fields are populated through the form which collects the appropriate details by manual input. So this is the core of the programs functionality.
I then have another section called 'Type' and this contains the information I supply in relation to the categories created... 'TypeName' with the 'TypeId' which auto-increments and populates the DB with a unique numeric value for each new Category I add. The final field is called 'TypeColor' which contains a Hex code for specific colours that are associated with a category on its creation. The list of colours however is stored in a separate section called 'LinkColor'. This can be added to depending upon your needs, for instance I currently use 3 colours to identify 3 categories on the calendar but can add a fourth one call it TEST assign a colour which I can select from the standard hex chart and enter its Name so #000 is defined as Black.
As you know ... the code now tells me that it has actually added 'TEST' to the database. What I would like it to do is tell me that 'TEST with the associated colour of Black' has been added to the database. The closest I have been able to get is that 'The category --> TEST <--- with the colour #000 Has been added to the database. The text that describes the Hex value is in a field called' ColorName' but can I heck drag it out !! It is referred to when you add the category in a drop down list showing that actual colour and the textual description for that colour. So it must be accessible. Do I need to reopen the database just access that field ? I've created a variable to try and store it before I close the DB as you showed me how to, but that is when I get the '#000 has been added.....' message. So I guess creating the variable is correct but I am not quite grasping how to pinpoint a specific field in the DB that I want to access. This is another way for me to learn what must be second nature to you, as I can associate it with something that is going to be useful. I know that only Admin will be able to use any of these web interface features to administer the system but ... without being sexist... my wife is one three of us :-0 so it really needs to be simple and totally fireproof so she can't mess up.. or get confused. My son is the other one and he is a top notch comms engineer so quite experienced at messing about with interfaces.
I let him loose on it tonight and he made quite a few valuable suggestions but I don't think I can even go there yet, it would be great if I could, a really slick interface but I wouldn't know where to start. His comment was... well why cant you just do it along the same lines as outlook..... stat date, finish date and let the software populate the calendar. Heck, I've only just learnt how to upgrade code to use 2 week blocks from the original 2 days! He also said that it would be handy if he could jump forward 1 year to perhaps next July to see if he could for instance book some time for a holiday. It would be quicker than currently having to keep pressing right arrow and pass through the year month by month. I could put in a drop menu to select year and month but am not too sure about how it would work or feel, but valid suggestions always appreciated. Lots to think about. Anyway, I will stick with this little issue and work through it, perhaps a penny will drop somewhere I will 'see the light'... ha ha ha.. I look forward to your reply ... DA :):thumb:
-
Re: VB Script will not remove modified data from Database
I'm not clear on what you are having a problem with. If you have the values already selected from the DB or sent from the form then you can just store them in a variable and display them. If you have only one of the values then you would need to do a lookup on the other one which you could do using a "Select FieldName From Table Where OtherFieldValue=ValueWeAreLookingFor"
So in your case maybe you need to look up from the LinkColor table where TypeColor= your hex code
-
Re: VB Script will not remove modified data from Database
Quote:
Originally Posted by
DataMiser
I'm not clear on what you are having a problem with. If you have the values already selected from the DB or sent from the form then you can just store them in a variable and display them. If you have only one of the values then you would need to do a lookup on the other one which you could do using a "Select FieldName From Table Where OtherFieldValue=ValueWeAreLookingFor"
So in your case maybe you need to look up from the LinkColor table where TypeColor= your hex code
I thought it was a simple thing to do but failed what I need is the information from the databasename , LinkColor , ColorName Field. The example you give does do just that, it tells me I have added category 'TEST' with the colour #000 associated to it.. The word BLACK is Kept in the LinkColor page in a field called ColorName ....and I cant get to it. What is the best way to manage this sort of request... You must be as crazy as me.... you write at 03:30 and I reply at 05:45.... I really must go to sleep or my wife will only have another go at me for getting carried away :eek::wave:
-
Re: VB Script will not remove modified data from Database
It should be simple to get it from the database provided the database is designed properly. You just need a field that links the value you want with the value you have.
Of course if the form is passing the values you need as data then you do not even need to look them up in the db as you would already have access to them.
The string to do a lookup may look something like this
Code:
SQLString="Select ColorName From LinkColor Where TypeColor='" & VarContainingHexValue & "'"
Assuming of course that the TypeColor Field exists in the LinkColor table and that it is of type text.
What time zone are you in? I am in the Eastern time zone here.
-
Re: VB Script will not remove modified data from Database
Quote:
Originally Posted by
DataMiser
It should be simple to get it from the database provided the database is designed properly. You just need a field that links the value you want with the value you have.
Of course if the form is passing the values you need as data then you do not even need to look them up in the db as you would already have access to them.
The string to do a lookup may look something like this
Code:
SQLString="Select ColorName From LinkColor Where TypeColor='" & VarContainingHexValue & "'"
Assuming of course that the TypeColor Field exists in the LinkColor table and that it is of type text.
What time zone are you in? I am in the Eastern time zone here.
Hi .. that's where I have the problem.. The TypeColor in held in the TYPE Table and not in the LinkColor Table there is only the hex #000 in there and TypeName in there. In the LinkColor table sits the ColorName and associated ColorCode Hex value. I want to pull out the ColorName associated with the new category. Again it does the job but doesn't display the information which I think is hidden because it is a value returned to the database. I'm actually GMT here in the middle of the UK :-) nice and warm for a change :-) DA
#
-
Re: VB Script will not remove modified data from Database
Like I said you need to use the link field
Sounds like you have the hex code in both tables so that is the link and you simply select the description [ColorName] from the LinkColor table Where the ColorCode= your hex value. Should be simple.
-
Re: VB Script will not remove modified data from Database
Quote:
Originally Posted by
DataMiser
Like I said you need to use the link field
Sounds like you have the hex code in both tables so that is the link and you simply select the description [ColorName] from the LinkColor table Where the ColorCode= your hex value. Should be simple.
Hi again.... I had a look at the bit of code in the .asp file which created the new category and there seems to be something there that would or maybe should do exactly what I wanted. So perhaps I was wanting to add code in the wrong place, that is already in this script but maybe not working correctly ??? Iadded the Dim Color variable but
Code:
<%
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()
%>
-
Re: VB Script will not remove modified data from Database
Well there you are telling it to write it to the browser but no way to tell if it actually shows up on your page. You need to make sure that when you try to write something to display in the browser that it is being done in the correct part of the code to actually be visible. Here you may want to assign the value of the colorname to a variable so you can write it at a later point in the script rather than rely on being able to do it inside your loop.
-
Re: VB Script will not remove modified data from Database
Hi :-)
I tried to import the code into the edit_asp file as shown below and it don't throw out errors but it didn't write any either. Then under that
Code:
<%
' If the form has been submitted (Flag = True), and the Category Name field isn't empty, update the record.
Else
Dim TypeRS
Dim MsgColor
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")
TypeRS.Update
TypeRS.Close()
Response.Redirect("category.asp")
End If
%></td>
<%
Dim Msg
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" Color
MsgColor Response.Write">" & LinkColorRS("ColorName") & "added""</option>"
LinkColorRS.MoveNext
Wend
LinkColorRS.Close()
CategoryRS.Close()
%>
going back a post about sql query.. I don't follow the logic of how I can do it but it seems to be the easier method.... are these 2 separate ways of doing the same thing. Still not sure how to display the value but will be giving more though to it in the morning :-) Thanks
-
Re: VB Script will not remove modified data from Database
That code should be throwing an error, There is no IF statement to go with the Else and End IF at the top
The part where you are trying to write the colorname looks pretty off as well, I don;t know if this is just an error from pasting or what but that should not be valid.
-
Re: VB Script will not remove modified data from Database
Quote:
Originally Posted by
davida1956
Hi :-)
I tried to import the code into the edit_asp file as shown below and it don't throw out errors but it didn't write any either. Then under that
Code:
<%
' If the form has been submitted (Flag = True), and the Category Name field isn't empty, update the record.
Else
Dim TypeRS
Dim MsgColor
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")
TypeRS.Update
TypeRS.Close()
Response.Redirect("category.asp")
End If
%></td>
<%
Dim Msg
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" Color
MsgColor Response.Write">" & LinkColorRS("ColorName") & "added""</option>"
LinkColorRS.MoveNext
Wend
LinkColorRS.Close()
CategoryRS.Close()
%>
going back a post about sql query.. I don't follow the logic of how I can do it but it seems to be the easier method.... are these 2 separate ways of doing the same thing. Still not sure how to display the value but will be giving more though to it in the morning :-) Thanks
Hi and thanks for that... Yes I had made a mistake when pasting.... That bit now works as expected again. It is the other bit of code that I think already has the value I want to extract inside there (ColorName) this is part of the category_edit.asp script which is where the new category information has to be entered. The code may have been posted incorrectly by me so I will add it again.
Code:
<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") & "'"
If (CategoryRS("TypeColor") = LinkColorRS("ColorCode")) Then Response.Write "selected"
Response.Write">" & LinkColorRS("ColorName") & "</option>"
LinkColorRS.MoveNext
Wend
LinkColorRS.Close()
CategoryRS.Close()
%>
</select>
I a assuming that I should be able to extract the ("ColorName") part of the bottom response.write statement? if the code is correct. How I would get that value into another script that works and already advises me that the category has been added is something else I am puzzled about. Perhaps I need to open the database again in that script which simply displays the Category Name which I have added, and tag on the category color I have selected???
DA
-
Re: VB Script will not remove modified data from Database
I can't tell what you are doing, that code is written inside an option tag.
If you want to retrieve that value and display it somewhere else in your script then you just need to use a variable
TheColor=LinkColorRS("ColorName")
then at some point on down the page you would write the var contents to your html page
The code as is is very hard to read with the VBScript and HTML mixed together and not properly indented, they are also incomplete so no way to tell what else is happening there.
-
Re: VB Script will not remove modified data from Database
Quote:
Originally Posted by
DataMiser
I can't tell what you are doing, that code is written inside an option tag.
If you want to retrieve that value and display it somewhere else in your script then you just need to use a variable
TheColor=LinkColorRS("ColorName")
then at some point on down the page you would write the var contents to your html page
The code as is is very hard to read with the VBScript and HTML mixed together and not properly indented, they are also incomplete so no way to tell what else is happening there.
Hi again and thanks for such a quick reply. I'm not too sure what you mean about VB in an option tag but will sit down in a bit and go through things again until I do ... or get stuck. I thought I had tried to do as you suggested with Colour=LinkColorRS("ColorName") but then it returned an error about something was not in the ordinal or something or that statement was incorrect as if it was expecting another "... will have another bash at it shortly and let you know..Cheers...:):thumb:
-
Re: VB Script will not remove modified data from Database
Quote:
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>"
That is also in a loop so you only want to grab the one that has been selected.
-
Re: VB Script will not remove modified data from Database
Quote:
Originally Posted by
DataMiser
That is also in a loop so you only want to grab the one that has been selected.
Hi and thanks again for your efforts and reply. I had to take some time out to go and help my son with a water leak in his house after he tried to fit a new kitchen sink !! If tried all sorts to actually extract the value of ColorName that I select with the new category and all without success. I either get variable undefined which I do understand, type mismatch, syntax error or unexpected end of statement plus a few others that perplex me just as much. Am I trying to do something that is not practical? Is it not possible to capture both the new category name and the colour I have chosen out of those defined in the database at the same point in time? Why does the hex value of that colour not translate to the colour name? I can extract that information ok. I add a category called TEST and select the colour Black and the information message will tell me that ......'The new category of 'TEST' with an associated colour of '#000' has been added to the database." So yeh ... still a bit confused. I understand how an sql query might look at a database and select details from specific fields, but where is the best place to put it? Would it be in the same code area that the open, connect and close DB statements are made? ....any advice?? much appreciated :-):thumb::)
-
Re: VB Script will not remove modified data from Database
The place to put it depends on where and how you want to display it.
Like I said you already have it there in that one piece of script you showed. You can assign it to a variable that you will use later in the script, just have to make sure you have the right scope on the variable or you can use a query and get it where you need it either will work with the variable being the faster since it does not require an additional query.
Can't say what you may have did wrong without seeing what you did.
-
Re: VB Script will not remove modified data from Database
Quote:
Originally Posted by
DataMiser
The place to put it depends on where and how you want to display it.
Like I said you already have it there in that one piece of script you showed. You can assign it to a variable that you will use later in the script, just have to make sure you have the right scope on the variable or you can use a query and get it where you need it either will work with the variable being the faster since it does not require an additional query.
Can't say what you may have did wrong without seeing what you did.
Hi and again thanks for your reply :-) I'm not even sure I can do what I want but here are my thoughts with what I see as being the information I want to use.....
This bit of script is in category_adit.asp. The code displays a form that allows you to enter a new category name and assigns it a selected colour which is predefined and stored in the LinkColor db form. It then hands over information to the category_add.asp script which then displays the message ... category ‘xyz’ has been added. which was the very first problem I had...
Code:
Dim Shade
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()
What I think I need to do is to create a variable called… ‘Shade’ for example and assign it the value given in the response.write”>”& LinkColorRS(“ColorName”) bit of script but I don’t know how to do that. Linkcolor contains the two fields of ColorName (text) and ColorCode(Hex)
The code is in the wrong part of the software to display whit the new category so somehow I need to move that value aver to the category_add.asp. That’s where the new category is displayed. I really look forward to your reply...regards :thumb:
DA
-
Re: VB Script will not remove modified data from Database
You have to do it a bit differently. Response.Write has nothing to do with setting variables and you also do not want to do it inside an option tag as that would just make the code harder to read
All you need to do is set the variable=the field but you need to do it only when it is the right field and in the right place.
For example given what you have there you would add another If statement inside your loop just like the one you have but outside the <option> tags
Code:
Dim Shade
Dim LinkColorRS
Set LinkColorRS = Server.CreateObject("ADODB.Recordset")
LinkColorRS.Open "SELECT * FROM LinkColor", Connect, 3, 3
While (Not LinkColorRS.EOF)
If (CategoryRS("TypeColor") = LinkColorRS("ColorCode")) Then Shade=LinkColorRS("ColorName")
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()
Also notice the way I intended the code, this makes it much easier to read where as what you had posted has some lines indented that should not be and others not indented that should be making it hard to follow.
Lines within a code block should be indented one step in from the outer portion of the block. Lines outside the block should not be indented. An indented line tells the reader that it must be in a block and causes them to look for that block also a line that is not indented may cause the reader to miss the block it is in just overall making it more time consuming and harder to read it correctly.
Now of course if you are wanting to write the value using a different script what I showed will do you no good at all as that Var will not be in scope. You will either have to do a lookup in the actual script you want to use it in or store it in a session var so it has a global scope.
-
Re: VB Script will not remove modified data from Database
Quote:
Originally Posted by
DataMiser
You have to do it a bit differently. Response.Write has nothing to do with setting variables and you also do not want to do it inside an option tag as that would just make the code harder to read
All you need to do is set the variable=the field but you need to do it only when it is the right field and in the right place.
For example given what you have there you would add another If statement inside your loop just like the one you have but outside the <option> tags
Code:
Dim Shade
Dim LinkColorRS
Set LinkColorRS = Server.CreateObject("ADODB.Recordset")
LinkColorRS.Open "SELECT * FROM LinkColor", Connect, 3, 3
While (Not LinkColorRS.EOF)
If (CategoryRS("TypeColor") = LinkColorRS("ColorCode")) Then Shade=LinkColorRS("ColorName")
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()
Also notice the way I intended the code, this makes it much easier to read where as what you had posted has some lines indented that should not be and others not indented that should be making it hard to follow.
Lines within a code block should be indented one step in from the outer portion of the block. Lines outside the block should not be indented. An indented line tells the reader that it must be in a block and causes them to look for that block also a line that is not indented may cause the reader to miss the block it is in just overall making it more time consuming and harder to read it correctly.
Now of course if you are wanting to write the value using a different script what I showed will do you no good at all as that Var will not be in scope. You will either have to do a lookup in the actual script you want to use it in or store it in a session var so it has a global scope.
Hiya and once again many thanks for your rapid reply. The advice you give me about code indentation is valuable... Maybe this is why I am finding it so hard to try and follow things. It seems like there is no real method in a lot of the original software. Now that you have shown me how to set the variable I understand that I cannot use it here despite the fact that this page of code defines all the required info.
The rest of what you write is a mystery to me in all honesty. I don't know what you mean by ...scope... (the constraints of the code function perhaps?). I do understand what lookup means and I have been trying to do that with no success, I'm not sure about syntax and related variables across tables.
The code as it stands works and all fields of the DB are populated correctly so in theory I suppose I can jump to the category_add.asp script that displays the Category name details gathered from category_edit.asp and then do a lookup on the value of the category ColorName??? but I don't think I can do that because I have to check a variable in the Itype table and cross reference that with the associated value in the LinkColor table requesting the associated ColorName.... or is my logic too complex.. or just mixed up ? Am I missing a very simple method or just lost again? It seems logical to extract the data as it is created but how you would move it in a session variable with global scope is way, way beyond me, I'm not even sure I grasp the concept of that yet.... Hmmm any words of wisdom ?? :ehh::confused:
-
Re: VB Script will not remove modified data from Database
Scope refers to where the variable is available. For example a Var defined in a Sub is only available in that sub. A Var declared at the top of the code before any subs is available to all the subs in that module/class.
ASP uses whats called Session vars which have a session scope, meaning they can be accessed from any script within the current user session and thus can be used to hold vars that need to be used by more than one script.
As for the lookup, I went over this already you just do a simple Select From Where query to get the value from the database that matches the code you have. look back a few posts for more info.
For example using a session var
Code:
If (CategoryRS("TypeColor") = LinkColorRS("ColorCode")) Then Session("Shade")=LinkColorRS("ColorName")
Elsewhere in your other script you would have
Code:
Response.Write(Session("Shade"))
Nothing to it ;)
-
Re: VB Script will not remove modified data from Database
Also...
You can pass variables values to an asp using arguments when you call it
-
Re: VB Script will not remove modified data from Database
Quote:
Originally Posted by
jggtz
Also...
You can pass variables values to an asp using arguments when you call it
Hi JG
My category_asp
I think I am getting confused as to what does what in which bit of code. This is the .asp file page where I add the new category, assign it a color and then hit the ADD button. So if I assign the name TEST with an associated color... RED, it then inserts that entry into the DB under the “Type” module. The color is however shown in hex… So what I see is….. TypeId=966…TypeName=TEST… TypeColor=#F00… which is perfectly correct.
Is this not the ideal point to query the database? If it is, how do I translate hex into the corresponding text color name? Do I need some sort of ‘lookup’ table or is that what I already have in the contents of LinkColor? That’s the module which contains a list of colors that I determine and where I give both the hex and text values. It has no association with the final choice. How would I do that?
Everything I see points back to this bit of code…. Is this where I use the session variable? I guess not because surely it would only return the hex value? If I SQLquery the DB it too would only return the Hex value again I guess. The “Type” module is the only place where these values are brought together and from there they are represented correctly on the calendar page.
I may have given you the wrong information so am not quite sure which way to turn right now. For completeness it is the category_add page that displays the ‘Category xxx’ has been added’ and it is also the place where I want to add the color I’ve selected. The category_edit script allows me to take an existing category and change the Category Name and Category Color then resubmit it to and update the database.
Code:
<%
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
%>
I understand what you have explained to me and now that I can see the construction it sort of makes sense so I will have a play and see what I can do with it and if I can make it work for other little bug fixes I would like to tackle. Again…. Many thanks for your continued help, I really appreciate it.
DA:thumb::)
-
Re: VB Script will not remove modified data from Database
I noted also that I am using Dreamweaver in split mode and when I look at just script mode the indentation is a little less mangled os will cut n paste from there :-)
-
Re: VB Script will not remove modified data from Database
Sorry DataMiser I thought you were the same person as JG who also seems to be following the thread.... just a little confusing :-)
-
Re: VB Script will not remove modified data from Database
Not just me... believe me, there are many more that are following this thread and your advances in resolving the problem... but DataMiser, as always, is doing the right thing... good luck!
-
Re: VB Script will not remove modified data from Database
Quote:
Originally Posted by
jggtz
Not just me... believe me, there are many more that are following this thread and your advances in resolving the problem... but DataMiser, as always, is doing the right thing... good luck!
Hi JG,
makes the impossible seem Didn't Know my sort of issues would interest anybody else, obviously go that wrong too :-) Yes DM is one heck smart guy who makes the impossible to some, factual for many, a good teacher with loads of patience and dedication which is great to see. Are there many more like DM on this site?
Regards DA :thumb::wave:
-
Re: VB Script will not remove modified data from Database
Quote:
Originally Posted by
DataMiser
Scope refers to where the variable is available. For example a Var defined in a Sub is only available in that sub. A Var declared at the top of the code before any subs is available to all the subs in that module/class.
ASP uses whats called Session vars which have a session scope, meaning they can be accessed from any script within the current user session and thus can be used to hold vars that need to be used by more than one script.
As for the lookup, I went over this already you just do a simple Select From Where query to get the value from the database that matches the code you have. look back a few posts for more info.
For example using a session var
Code:
If (CategoryRS("TypeColor") = LinkColorRS("ColorCode")) Then Session("Shade")=LinkColorRS("ColorName")
Elsewhere in your other script you would have
Code:
Response.Write(Session("Shade"))
Nothing to it ;)
Hi DM .. haven't heard from you in a while and was wondering if my post got through to you as I replied to somebody else by mistake. I've tried some of the suggestions you gave me but without much joy, for example ColorName is not in the same table as CategoryColor. I'm a little confused right now but think my explanation of the situation is still pretty much the same as it was when I wrote to you 4 or 5 days ago.......
I think I am getting confused as to what does what in which bit of code. This is the .asp file page where I add the new category, assign it a color and then hit the ADD button. So if I assign the name TEST with an associated color... RED, it then inserts that entry into the DB under the “Type” module. The color is however shown in hex… So what I see is….. TypeId=966…TypeName=TEST… TypeColor=#F00… which is perfectly correct.
Is this not the ideal point to query the database? If it is, how do I translate hex into the corresponding text color name? Do I need some sort of ‘lookup’ table or is that what I already have in the contents of LinkColor? That’s the module which contains a list of colors that I determine and where I give both the hex and text values. It has no association with the final choice. How would I do that?
Everything I see points back to this bit of code…. Is this where I use the session variable? I guess not because surely it would only return the hex value? If I SQLquery the DB it too would only return the Hex value again I guess. The “Type” module is the only place where these values are brought together and from there they are represented correctly on the calendar page.
I may have given you the wrong information so am not quite sure which way to turn right now. For completeness it is the category_add page that displays the ‘Category xxx’ has been added’ and it is also the place where I want to add the color I’ve selected. The category_edit script allows me to take an existing category and change the Category Name and Category Color then resubmit it to and update the database.
[code]
<%
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
%>
[code/]
I understand what you have explained to me and now that I can see the construction it sort of makes sense so I will have a play and see what I can do with it and if I can make it work for other little bug fixes I would like to tackle. Again…. Many thanks for your continued help, I really appreciate it...
-
Re: VB Script will not remove modified data from Database
I had not saw any more questions. Am not sure what the question is now. Assuming that the value you are wanting to display is in the field called ColorName then what i showed you should work see post #35 and #37
-
Re: VB Script will not remove modified data from Database
Quote:
Originally Posted by
DataMiser
I had not saw any more questions. Am not sure what the question is now. Assuming that the value you are wanting to display is in the field called ColorName then what i showed you should work see post #35 and #37
Hi DM.. I wondered why I hadn't heard from you as you always answer very quickly :-) I did try what you suggested but it gave m no end of problems. In one instance it removed my ability to add new categories and I couldn't edit the ones that were there. You suggested that providing the db was designed correctly that I should e able to extract the details I needed from the LinkColor table. My understanding is that 'LinkColor' contains only all of the current combinations of colors available. It is when you create a new category that this information is displayed. Once you create this information it is stored in the 'Type' table as three values....'Id' ..ColorName and ColorCode. I want to extract the color name associated with the new category and display it alongside the message advising me that the new category has been created. The code I showed in my last post is where I think it should be but I am not sure how to access it.
-
Re: VB Script will not remove modified data from Database
I am confused you have to get the value from where the value is stored. If it is not in the LinkColor table then you can not get it from there. If the type table has the code and the value you want to display then you may need to do a lookup and get it from there. This is very easy to do Just a simple Select where statement
"Select ColorName From [Type] Where ColorCode='" & VarColorCode &"'"
Assuming of course that colorcode is a text field [would not need the ' characters if it is a numeric field type
Also assumign that VarColorCode is the name of the var holding the color code in question.
-
Re: VB Script will not remove modified data from Database
Wow... fast .... caught me out :-) I tried that but I don't think it works. The value in the Type table 'TypeColor' is a hex value associated with a given value held in LinkColor table 'ColorCode' which has the text value in the ColorName field. So when creating a new category there is a drop down table with all of the available colours I can choose from. So I see the word 'BLUE' and it is displayed in the colour blue. I don't know how to capture that information at the point where this information is passed onto the next routine. Does this make sense ??
-
Re: VB Script will not remove modified data from Database
No not really. You said
Quote:
Once you create this information it is stored in the 'Type' table as three values....'Id' ..ColorName and ColorCode.
If these three fields are there then you have all you need.
Also you keep talking about being stored as Hex value but that is not a data type. either it is stored as a numeric type or a string/text type. The SQL string will be different for one type from the other.
if I understand you correctly at the point where you want to display the color name you have the colorcode and also there is a table that holds both the color code and the colorname that is associated to that code if this is true then it is as I said very simple. You just do a select on the table like I showed you and the resulting RS should have 1 record with just one field in it and that field will be the colorname you want.
It doesn't really matter what you have on your web page, clouds the issue more than it helps. If you tried the select method and had an issue then you should show us what you tried as you must have did something wrong.
The other options are to pass the value to the script either using a hidden field or as part of the querystring or setting it in a Session var.
Of the various options the Select statement is probably the most simple.
-
Re: VB Script will not remove modified data from Database
Quote:
Originally Posted by
DataMiser
No not really. You said
If these three fields are there then you have all you need.
Also you keep talking about being stored as Hex value but that is not a data type. either it is stored as a numeric type or a string/text type. The SQL string will be different for one type from the other.
if I understand you correctly at the point where you want to display the color name you have the colorcode and also there is a table that holds both the color code and the colorname that is associated to that code if this is true then it is as I said very simple. You just do a select on the table like I showed you and the resulting RS should have 1 record with just one field in it and that field will be the colorname you want.
It doesn't really matter what you have on your web page, clouds the issue more than it helps. If you tried the select method and had an issue then you should show us what you tried as you must have did something wrong.
The other options are to pass the value to the script either using a hidden field or as part of the querystring or setting it in a Session var.
Of the various options the Select statement is probably the most simple.
Hi and thanks again.... That has totally confused me other than to say the value I to display is obviously textual. You give many options but I must be having a bad day because I can't figure things out. I know where the code is and where I want display the new information but I don't know how to perform the select statement. Is this snip of code where I should apply the select statement ? I have shown where it should be... just after the first message advising that the new category has been added to the database....... WITH THE ASSOCIATED COLOR......
[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"">A New Category---> " & Request("TypeName") & " <--- Has Now Been Added To The Database." ......WITH THE ASSOCIATED COLOUR 'ColorName'
Else
Msg="<p class=""textEvent"">You Must Enter A Valid Category Name ! ... This Field Cannot Be Left Blank !</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>
<% Response.Write(Msg) %>
</p>
[code/]
where do I put the select statement and how does it access the TYPE in my db... A lot confused...:confused::thumb: