Querystring Values spaces causing errors

Discussion in 'ASP General' started by JP SIngh, Jul 13, 2004.

  1. JP SIngh

    JP SIngh Guest

    I am trying to update my table with a value passed though the
    request.querystring method but as you can see from the sql statement below
    it is causing errors.

    In this case the name of the department as displayed is "Arts and
    Entertainment" but it is giving me something strange when I try to use the
    variable

    update empprofile set department ='Arts%20%26%20Entertainment' where
    employeenumber =219104
    Microsoft JET Database Engine error '80004005'

    You cannot add or change a record because a related record is required in
    table 'Departments'.

    /admin/updatedept.asp, line 32

    Any solutions

    Regards

    Jas
     
    JP SIngh, Jul 13, 2004
    #1
    1. Advertising

  2. JP SIngh

    Maarten Guest

    Replace (request.querystring ,"%20", " ")


    "JP SIngh" <> schreef in bericht
    news:%...
    > I am trying to update my table with a value passed though the
    > request.querystring method but as you can see from the sql statement below
    > it is causing errors.
    >
    > In this case the name of the department as displayed is "Arts and
    > Entertainment" but it is giving me something strange when I try to use

    the
    > variable
    >
    > update empprofile set department ='Arts%20%26%20Entertainment' where
    > employeenumber =219104
    > Microsoft JET Database Engine error '80004005'
    >
    > You cannot add or change a record because a related record is required in
    > table 'Departments'.
    >
    > /admin/updatedept.asp, line 32
    >
    > Any solutions
    >
    > Regards
    >
    > Jas
    >
    >
    >
    >
     
    Maarten, Jul 13, 2004
    #2
    1. Advertising

  3. If you use post instead of get, you can avoid this error.

    If you use id numbers instead of long, un-URL-friendly descriptions to
    identify rows, you can avoid this error.

    --
    http://www.aspfaq.com/
    (Reverse address to reply.)




    "JP SIngh" <> wrote in message
    news:#...
    > I am trying to update my table with a value passed though the
    > request.querystring method but as you can see from the sql statement below
    > it is causing errors.
    >
    > In this case the name of the department as displayed is "Arts and
    > Entertainment" but it is giving me something strange when I try to use

    the
    > variable
    >
    > update empprofile set department ='Arts%20%26%20Entertainment' where
    > employeenumber =219104
    > Microsoft JET Database Engine error '80004005'
    >
    > You cannot add or change a record because a related record is required in
    > table 'Departments'.
    >
    > /admin/updatedept.asp, line 32
    >
    > Any solutions
    >
    > Regards
    >
    > Jas
    >
    >
    >
    >
     
    Aaron [SQL Server MVP], Jul 13, 2004
    #3
  4. JP SIngh

    Bullschmidt Guest

    Classic ASP Design Tips - QueryString
    http://www.bullschmidt.com/devtip-querystring.asp

    Example URL with a querystring:
    http://www.mysite.com/mydir/mypg.asp?myvar1=hey&myvar2=ho

    Because a variable might contain some odd characters like spaces, it's
    usually a good idea to use Server.URLEncode when creating a querystring
    from a variable:
    <a href="http://www.mysite.com/mypage?id=<%=
    Server.URLEncode(objRS("MyIDFldFromDB")) %>">objRS("MyIDFldFromDB")</a>

    And in the page that is opened you can use Request.QueryString("id") to
    get the value of id.

    Best regards,
    J. Paul Schmidt, Classic ASP Web Designer
    http://www.Bullschmidt.com
    Classic ASP Design Tips, ASP Web Database Demo, ASP Bar Chart Tool...


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Bullschmidt, Jul 13, 2004
    #4
  5. The error message is indicating that the database is designed in such a
    way that a matching record must exist in the 'Departments' table.
    Basically, you're trying to add a record to a table that has a specified
    relationship to the 'Departments' table. The problem is not neccessarily
    related to the querystring values, however it might be.

    Double check that there is a record in the 'Departments' table for 'Arts
    & Entertainment'. If a record doest exist, then the problem has to do
    with the fact that the special characters are encoded.

    'Arts%20%26%20Entertainment' is 'Arts and Entertainment' as far as HTML
    is concerned. However, the same statement is
    'Arts%20%26%20Entertainment' when it comes to the database. The DB is
    seeing the string literally as it appears. So what you need to do is to
    convert the encoded characters back to their text versions. I've never
    dealt with this particular problem. Server.HTMLEncode() can be used to
    encoded the characters initially, however I'm not familar with a means
    to unencode them.

    You shouldn't have to encode the string to begin with though.
    ?department=Arts & Entertainment
    should work without any problems.*

    David H
    *In the event that this doesn't work and causes catastrophic results
    including but not limited to the destruction of mankind, you're on your
    own.

    Secon

    JP SIngh wrote:

    > I am trying to update my table with a value passed though the
    > request.querystring method but as you can see from the sql statement below
    > it is causing errors.
    >
    > In this case the name of the department as displayed is "Arts and
    > Entertainment" but it is giving me something strange when I try to use the
    > variable
    >
    > update empprofile set department ='Arts%20%26%20Entertainment' where
    > employeenumber =219104
    > Microsoft JET Database Engine error '80004005'
    >
    > You cannot add or change a record because a related record is required in
    > table 'Departments'.
    >
    > /admin/updatedept.asp, line 32
    >
    > Any solutions
    >
    > Regards
    >
    > Jas
    >
    >
    >
    >
     
    David C. Holley, Jul 19, 2004
    #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. Kerry Shetline
    Replies:
    1
    Views:
    6,239
    Kerry Shetline
    Sep 4, 2003
  2. John B. Matthews
    Replies:
    4
    Views:
    684
    John B. Matthews
    Sep 12, 2008
  3. Roedy Green
    Replies:
    3
    Views:
    644
  4. Tomasz Chmielewski

    [CSS] how can I show spaces as spaces?

    Tomasz Chmielewski, Sep 5, 2009, in forum: HTML
    Replies:
    21
    Views:
    1,650
    Jan C. Faerber
    Sep 10, 2009
  5. Tomasz Chmielewski

    how can I show spaces as spaces, part 2

    Tomasz Chmielewski, Sep 9, 2009, in forum: HTML
    Replies:
    14
    Views:
    903
    Jan C. Faerber
    Sep 10, 2009
Loading...

Share This Page