Values of location field gets truncated in a asp generated table

Discussion in 'ASP General' started by Jack, Jan 11, 2006.

  1. Jack

    Jack Guest

    THE FOLLOWING IS A PART OF CODE FROM A ASP PAGE

    <%
    sql01 = "SELECT COUNT(*) AS reccount FROM Equipmenttbl "
    sql01 = sql01 & "WHERE Equipmenttbl.GrantID = " & GrantID

    'Response.Write sql01 & "<br>"
    'Response.End

    i = 0
    sql01 = "SELECT equipmentTbl.* FROM EquipmentTbl "
    sql01 = sql01 & "WHERE EquipmentTbl.GrantID = " & GrantID
    response.write "SELECT SQL:" & sql01
    'response.end
    rstemp.open sql01
    'set rstemp=conntemp.execute(sql01)
    Do until rstemp.eof
    i = i + 1
    response.write "<TR>" & vbCRLF
    strLink = "<TD WIDTH=1% ><INPUT TYPE='HIDDEN' NAME='EquipmentID_" & i &
    "' VALUE=" & rstemp("EquipmentID") & "></TD>" & vbCRLF
    response.write strLink & vbCRLF
    if session("locked")<>"Y" then
    strLink = "<TD WIDTH=1% ><A TITLE='Click here to delete line'
    HREF='ConfirmDeleteEquipmentLine.asp?EquipmentID=" & rstemp("EquipmentID") &
    "'>Delete</A></TD>" & vbCRLF
    response.write strLink & vbCRLF
    else
    strLink = "<TD WIDTH=1% ></A></TD>" & vbCRLF
    response.write strLink & vbCRLF
    end if
    strLink = "<TD WIDTH=10% ALIGN=LEFT><INPUT TYPE='text' SIZE=10
    NAME='serialnum_"& i & "' VALUE='" & rstemp("SerialNumber") & "'></TD>" &
    vbCRLF
    response.write strLink & vbCRLF

    strLink = "<TD WIDTH=40% ALIGN=LEFT><INPUT TYPE='text' SIZE=45
    NAME='Desc_"& i & "' VALUE='" & rstemp("Description") & "'></TD>" & vbCRLF
    response.write strLink & vbCRLF

    strLink = "<TD WIDTH=10% ALIGN=LEFT><INPUT TYPE='text' SIZE=28
    NAME='Location_" & i & "' VALUE='" & rstemp("Location") & "'></TD>" & vbCRLF
    response.write strLink & vbCRLF


    response.write rstemp("Location") & "<br>"

    strLink = "<TD WIDTH=10% ALIGN=RIGHT><INPUT TYPE='text' SIZE=12
    NAME='Cost_" & i & "' VALUE='" & rstemp("Cost") & "' style='text-align:
    right;'></TD>" & vbCRLF
    response.write strLink & vbCRLF

    strLink = "<TD WIDTH=20% ALIGN=CENTER><INPUT TYPE='text' SIZE=1
    NAME='Expmonth_" & i & "'VALUE='" & month(rstemp("DateAcquired")) & "'>/
    <INPUT TYPE='text' SIZE=1 NAME='ExpDay_" & i & "'VALUE='" &
    day(rstemp("DateAcquired")) & "'>/ <INPUT TYPE='text' SIZE=2 NAME='Expyear_"
    & i & "'VALUE='" & year(rstemp("DateAcquired")) & "'></TD>" & vbCRLF
    '***************
    response.write strLink & vbCRLF

    response.write "</TR>" & vbCRLF

    totalcost=totalcost+rstemp("Cost")
    'save the check box value and Financial Officers name. Should be the
    same on
    'all records as it will get updated each time the UPDATE button is
    clicked.
    'Check box and name are redundant but this is the way it was originally
    set up
    'Decided to go with the flow rather than trying to save these values in
    the
    'GrantTBL so they are not redundant.
    ICertify = rstemp("ICertify")
    FinancialOfficer = rstemp("FinancialOfficer")
    rstemp.movenext
    loop
    rstemp.close
    %>
    </TR>


    In the above code which is a input screen (as well as display screen) all
    the equipment rows of a particular GrantId is captured
    from the above recordset and is displayed in a table format by the above
    loop. The problem is that for the values
    of location for various rows, if there is a single quote in the row, then
    only part of the value is captured in the
    location column of this generated table.

    I have added a response.write rstemp("Location") & "<br>" statement to see
    the values that are retrieved
    from the backend table corresponding to the locaion field.In the present
    scenario the following was the result i.e. here we can see that the single
    quotes
    are retrieved as is. The results are the following:

    Conference Room's Cabinet
    Server Rooom
    Don's Room
    Server Room

    However, in the asp generated table for the location column the values are
    as follows:
    Conference Room
    Server Rooom
    Don
    Server Room

    Thus all character including and after the single quote(') is getting
    truncated.

    I have no idea why this truncation is happening when the rows are being
    dynamically formed in the asp table
    but retrieves the whole value by issusing a response.write statement. And
    what is the resolution for this problem so
    that the location field in the generated asp table shows data without any
    truncation.

    Any help is appreciated.

    Thanks in advance.
     
    Jack, Jan 11, 2006
    #1
    1. Advertising

  2. Jack

    Avlan Guest

    This has something to do with the fact that SQL-statements use the
    '-character. I think the solution was something with putting the ' in
    between two ", so it will be something like "'" (or " ' " with spaces).

    When a '-character is used, you effectively tell the server the
    SQL-string ends there.

    I'm probably a bit vague but thats because its been some time since I
    had sort of the same problem ;-)
     
    Avlan, Jan 11, 2006
    #2
    1. Advertising

  3. Jack

    Jack Guest

    Re: Values of location field gets truncated in a asp generated tab

    Thanks for your help Alvan. I appreciate it. However, it did not help me
    resolve this problem. Hence I had to post this message again to see if
    someone has some suggestion fo resolution of this problem.

    "Avlan" wrote:

    > This has something to do with the fact that SQL-statements use the
    > '-character. I think the solution was something with putting the ' in
    > between two ", so it will be something like "'" (or " ' " with spaces).
    >
    > When a '-character is used, you effectively tell the server the
    > SQL-string ends there.
    >
    > I'm probably a bit vague but thats because its been some time since I
    > had sort of the same problem ;-)
    >
    >
     
    Jack, Jan 11, 2006
    #3
  4. Jack

    Paxton Guest

    Avlan wrote:
    > This has something to do with the fact that SQL-statements use the
    > '-character. I think the solution was something with putting the ' in
    > between two ", so it will be something like "'" (or " ' " with spaces).
    >
    > When a '-character is used, you effectively tell the server the
    > SQL-string ends there.
    >
    > I'm probably a bit vague but thats because its been some time since I
    > had sort of the same problem ;-)


    No - it's HTML 101.

    The OP was using a single quote to delimit his attribute values. This
    is OK if they contain double quotes, but when the browser reaches the
    single quote in the value, it figures it has reached the end of the
    value, so stops writing.

    HTML specification is that you use doublequotes for attribute values.
    In XHTML, it's mandatory.

    /P.
     
    Paxton, Jan 11, 2006
    #4
  5. Jack

    Paxton Guest

    Paxton wrote:
    > Avlan wrote:
    > > This has something to do with the fact that SQL-statements use the
    > > '-character. I think the solution was something with putting the ' in
    > > between two ", so it will be something like "'" (or " ' " with spaces).
    > >
    > > When a '-character is used, you effectively tell the server the
    > > SQL-string ends there.
    > >
    > > I'm probably a bit vague but thats because its been some time since I
    > > had sort of the same problem ;-)

    >
    > No - it's HTML 101.
    >
    > The OP was using a single quote to delimit his attribute values. This
    > is OK if they contain double quotes, but when the browser reaches the
    > single quote in the value, it figures it has reached the end of the
    > value, so stops writing.
    >
    > HTML specification is that you use doublequotes for attribute values.
    > In XHTML, it's mandatory.
    >
    > /P.


    Oops. Meant to say HTML *recommendation*, not specification.

    /P.
     
    Paxton, Jan 11, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bertus Dam
    Replies:
    5
    Views:
    863
    Bertus Dam
    Aug 29, 2003
  2. jza

    File name gets truncated

    jza, May 8, 2004, in forum: C Programming
    Replies:
    9
    Views:
    389
    Darrell Grainger
    May 10, 2004
  3. doltharz
    Replies:
    11
    Views:
    278
    doltharz
    Aug 3, 2003
  4. Mike
    Replies:
    1
    Views:
    262
    Bob Barrows [MVP]
    Aug 25, 2005
  5. Jack
    Replies:
    11
    Views:
    288
Loading...

Share This Page