ASP with Access Database (Input Text - Value Display)

Discussion in 'ASP General' started by magix, Feb 12, 2006.

  1. magix

    magix Guest

    Hi,

    I'm using Access Database with ASP. There is one particular thing that I
    have issue with.
    My purpose is for user to update their own profile. Their existing profile
    information will be display in Edit Form format. The problem is if the field
    has space, the second word will not display, when I display in input text
    format.

    E.g if My first name "User_FirstName" in my table has entry, let say "David
    Johnson" as FirstName, when I execute following code and do a input text, it
    will display "David" only.

    I have following code.

    <% Dim MyProfile

    Set MyProfile= Server.CreateObject("ADODB.Connection")
    ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath
    ("database/users.mdb") & ";Jet OLEDB:Database Password=password"
    MyProfile.Open(ConnStr)


    SQLtemp = "SELECT * FROM UserAccount WHERE User_UserName = '" &
    Request.Cookies("UserName") & "' "
    Set rs = MyProfile.Execute(SQLtemp)

    while not rs.eof

    If Request.Cookies("UserName") = rs("User_UserName") Then

    dim Your_FirstName
    Your_FirstName = rs("User_FirstName")
    dim Your_LastName
    Your_LastName = rs("User_LastName")
    dim Your_UserName
    Your_UserName = rs("User_UserName")
    dim Your_Password
    Your_Password = rs("User_Password")
    dim Your_Email
    Your_Email = rs("User_Email")
    dim Your_Address
    Your_Address = rs("User_Address")
    dim Your_City
    Your_City = rs("User_City")
    dim Your_Country
    Your_Country = rs("User_Country")
    dim Your_Date_In
    Your_Date_In = rs("User_EntryDate")
    dim Your_Company
    Your_Company = rs("User_Company")
    dim Your_Designation
    Your_Designation = rs("User_Designation")
    dim Your_Phone
    Your_Phone = rs("User_Phone")
    End If

    rs.MoveNext
    Wend
    rs.Close
    MyProfile.Close
    set MyProfile = Nothing

    %>

    ....
    <td width="118" valign="top"><span class="bold">First
    Name:</span></td>
    <td width="624" valign="top"><input type="text" name="xFirstName"
    size="20" value=<%response.write Your_FirstName %> maxlength="15"></td>

    .... This will display "David"



    So, if I'm not using input type text to display is, for example,

    <td width="118" valign="top"><span class="bold">First
    Name:</span></td>
    <td width="624" valign="top"><%response.write Your_FirstName %></td>
    ... This will display "David Johnson"


    May I know why ? and how to fix it to display "David Johnson" in input text
    format.

    Thank you,

    Regards,
    Magix
     
    magix, Feb 12, 2006
    #1
    1. Advertisements

  2. magix

    magix Guest

    Thanks Dave. It works.

    "Dave Anderson" <> wrote in message
    news:...
    > magix wrote:
    > > ...The problem is if the field has space, the second
    > > word will not display, when I display in input text format...

    >
    > That is usually because you aren't using attribute quotes.
    >
    >
    > > <input type="text" name="xFirstName" size="20"
    > > value=<%response.write Your_FirstName %>
    > > maxlength="15">

    >
    > Exactly. If you look at the generated HTML, you will see:
    >
    > <input type="text" name="xFirstName" size="20"
    > value=David Johnson maxlength="15">
    >
    > I suggest you change three things. The first is just a matter of
    > convenience:
    > . Use the <%= %> token for Response.Write
    > . Use attibute quotes
    > . Use Server.HTMLEncode when writing something a user may have typed
    >
    > In short, this will suffice:
    >
    > <input value="<%=Server.HTMLEncode(Your_FirstName)%>" ...>
    >
    >
    >
    > --
    > Dave Anderson
    >
    > Unsolicited commercial email will be read at a cost of $500 per message.

    Use
    > of this email address implies consent to these terms. Please do not

    contact
    > me directly or ask me to contact you directly for assistance. If your
    > question is worth asking, it's worth posting.
    >
    >
     
    magix, Feb 12, 2006
    #2
    1. Advertisements

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. Noozer
    Replies:
    2
    Views:
    1,297
    Noozer
    Aug 1, 2005
  2. =?Utf-8?B?a21jY29za2V5?=

    ACCESS AN ACCESS DATABASE FROM ASP.NET INTRANET SCENARIO

    =?Utf-8?B?a21jY29za2V5?=, Apr 24, 2007, in forum: ASP .Net
    Replies:
    7
    Views:
    703
    =?Utf-8?B?a21jY29za2V5?=
    Apr 30, 2007
  3. Sam
    Replies:
    2
    Views:
    735
    Bjorn Sagbakken
    Jul 12, 2007
  4. kmccoskey
    Replies:
    2
    Views:
    426
    Paul Clement
    Apr 27, 2007
  5. william

    Access remote access database from ASP

    william, Feb 10, 2004, in forum: ASP General
    Replies:
    5
    Views:
    267
    william
    Feb 13, 2004
  6. Replies:
    0
    Views:
    222
  7. Susan Cranford
    Replies:
    2
    Views:
    601
  8. Dwizz
    Replies:
    10
    Views:
    619
Loading...