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

Re: VB Script will not remove modified data from Database

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

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.

Re: VB Script will not remove modified data from Database

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

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

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.

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

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")

Re: VB Script will not remove modified data from Database

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.

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

Last edited by davida1956; July 26th, 2013 at 09:05 PM.
Reason: additional info

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!

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?

Re: VB Script will not remove modified data from Database

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.

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