CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 8 FirstFirst 12345 ... LastLast
Results 16 to 30 of 114
  1. #16
    Join Date
    Jun 2013
    Posts
    102

    Re: VB Script will not remove modified data from Database

    Quote Originally Posted by DataMiser View Post
    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 :-)

  2. #17
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: VB Script will not remove modified data from Database

    You mean as in "Select FieldName From Table" ?
    Always use [code][/code] tags when posting code.

  3. #18
    Join Date
    Jun 2013
    Posts
    102

    Re: VB Script will not remove modified data from Database

    Quote Originally Posted by DataMiser View Post
    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
    Last edited by davida1956; July 18th, 2013 at 09:22 PM. Reason: Missing Words

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

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

  5. #20
    Join Date
    Jun 2013
    Posts
    102

    Re: VB Script will not remove modified data from Database

    Quote Originally Posted by DataMiser View Post
    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

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

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

  7. #22
    Join Date
    Jun 2013
    Posts
    102

    Re: VB Script will not remove modified data from Database

    Quote Originally Posted by DataMiser View Post
    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
    #

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

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

  9. #24
    Join Date
    Jun 2013
    Posts
    102

    Re: VB Script will not remove modified data from Database

    Quote Originally Posted by DataMiser View Post
    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()
    %>

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

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

  11. #26
    Join Date
    Jun 2013
    Posts
    102

    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

  12. #27
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

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

  13. #28
    Join Date
    Jun 2013
    Posts
    102

    Re: VB Script will not remove modified data from Database

    Quote Originally Posted by davida1956 View Post
    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

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

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

  15. #30
    Join Date
    Jun 2013
    Posts
    102

    Re: VB Script will not remove modified data from Database

    Quote Originally Posted by DataMiser View Post
    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...

Page 2 of 8 FirstFirst 12345 ... 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