Default value for url parameter

Ask a Question related to Dreamweaver AppDev, Design and Development.

  1. #1

    Default Default value for url parameter

    Hello,

    I am using ASP.NET and connecting to an Access database. I read that I could
    use the % symbol as the default value to show all records from an Access
    dataset. Is that right? I can't get it to work. When I test the page it gives
    me an error saying that the input string was not in the correct format.

    I have a simple sql statment:
    SELECT *
    FROM CategoryList
    WHERE CategoryID = ?

    I have the folloing code for the url parameter @CatID
    IIF((Request.QueryString("CatID") <> Nothing),
    Request.QueryString("CatID"), "%")

    I also tried putting the "%" outside of the iif statement like this.
    (IIF((Request.QueryString("CatID") <> Nothing),
    Request.QueryString("CatID"), " ")) + %

    If I set the default value to something like "2", it works beautifully. But
    how can I get the wildcard to work? I just can't figure it out. Does anyone
    know? Thanks so much.

    James

    (Im on XP pro and using IIS with Dreamweaver MX 2004)


    dischord13 Guest

  2. Similar Questions and Discussions

    1. asp.net 2.0 SqlDataSource control parameter default value
      how can i set the default value of a control parameter to a wildcard character? i am using sql
    2. Setting index.cfm as the default document??? Yes, it hasbeen added as a default document in IIS.
      I am having trouble getting IIS to recognize the default index.cfm document, and I was wondering if anyone could give me some guidance. I created a...
    3. Date Parameter For Saved Parameter Queries
      Hi again, I finally got to using saved parameter queries in my application (a big thank you to Bob Barrows for helping me with this). Currently...
    4. #23104 [Asn->Csd]: Default array parameter value
      ID: 23104 Updated by: iliaa@php.net Reported By: mkong at intisoft dot com -Status: Assigned +Status: ...
    5. #23104 [Ver->Asn]: Default array parameter value
      ID: 23104 Updated by: iliaa@php.net Reported By: mkong at intisoft dot com -Status: Verified +Status: ...
  3. #2

    Default Re: Default value for url parameter

    Try * instead for Access... % is the wildcard for SQL Server...

    HTH,
    Drew

    "dischord13" <webforumsuser@macromedia.com> wrote in message
    news:d437ea$9hj$1@forums.macromedia.com...
    > Hello,
    >
    > I am using ASP.NET and connecting to an Access database. I read that I
    > could
    > use the % symbol as the default value to show all records from an Access
    > dataset. Is that right? I can't get it to work. When I test the page it
    > gives
    > me an error saying that the input string was not in the correct format.
    >
    > I have a simple sql statment:
    > SELECT *
    > FROM CategoryList
    > WHERE CategoryID = ?
    >
    > I have the folloing code for the url parameter @CatID
    > IIF((Request.QueryString("CatID") <> Nothing),
    > Request.QueryString("CatID"), "%")
    >
    > I also tried putting the "%" outside of the iif statement like this.
    > (IIF((Request.QueryString("CatID") <> Nothing),
    > Request.QueryString("CatID"), " ")) + %
    >
    > If I set the default value to something like "2", it works beautifully.
    > But
    > how can I get the wildcard to work? I just can't figure it out. Does
    > anyone
    > know? Thanks so much.
    >
    > James
    >
    > (Im on XP pro and using IIS with Dreamweaver MX 2004)
    >
    >

    Drew Guest

  4. #3

    Default Re: Default value for url parameter

    I've tried % and * and ? and just about every symbol on the keyboard. I still
    get the same message "System.FormatException: Input string was not in a correct
    format."

    That's good to know that that % works for SQL Server because I will upgrate
    eventually. I'm beginning to think that it is not possilbe to do it in Access.
    Has anyone managed to do this successfully?

    dischord13 Guest

  5. #4

    Default Re: Default value for url parameter

    Might sound obvious, but be sure to wrap the wildcard with apostrophe's a la

    I have a simple sql statment:
    SELECT *
    FROM CategoryList
    WHERE CategoryID = '%'

    also try the like keyword. so like '%'


    On 19/4/05 4:17 pm, in article d437ea$9hj$1@forums.macromedia.com,
    "dischord13" <webforumsuser@macromedia.com> wrote:
    > I have a simple sql statment:
    > SELECT *
    > FROM CategoryList
    > WHERE CategoryID = ?
    Calvin Willman Guest

  6. #5

    Default Re: Default value for url parameter

    Thanks for the reply. You are right Calvin, I should be using LIKE (how did I
    miss that??) , but I am still getting the same error message. "Input string was
    not in a correct format"

    I found a macromedia help reference that specifically stated that I can use
    the % as the default value for microsoft Access in an Asp.net page. It said to
    use the following format.

    (IIf((Request.Form("txtCity") <> Nothing),
    Request.Form("txtCity"), "")) + "%"

    Again, this format works great if I delete the "%" and put any default value
    like "2" or something. The only thing that doesn't work is the % character!!! I
    just can't figure out why not. It's driving me crazy. Am I reading the
    reference incorrectly? It shows the same syntax for the SQL statement I am
    using with WHERE CategoryID = ? without any apostrophe or quotes.

    Here is the reference I am referring to:
    [url]http://livedocs.macromedia.com/dreamweaver/mx2004/using/wwhelp/wwhimpl/common/ht[/url]
    ml/wwhelp.htm?context=Using_Dreamweaver&file=43_rad10 .htm

    Anyone have any other ideas? Feel free to say any solution you can think of
    even if it sounds obvious. I am very inexperienced. Thanks!
    James

    dischord13 Guest

  7. #6

    Default Re: Default value for url parameter

    I'm not too familiar with how Dreamweaver creates it's sql statements...
    certainly with reference to using the ? place holder but,

    I'm sure the wildcard character explicitly needs to have single quotes
    around it in the final statement that gets executed. So try... amending the
    IIF line force the wildcard to have apostrophe's "\'%\'".

    Other than that... I'm out of ideas with this.

    On 19/4/05 7:06 pm, in article d43hab$nq6$1@forums.macromedia.com,
    "dischord13" <webforumsuser@macromedia.com> wrote:
    > Thanks for the reply. You are right Calvin, I should be using LIKE (how did I
    > miss that??) , but I am still getting the same error message. "Input string
    > was
    > not in a correct format"
    >
    > I found a macromedia help reference that specifically stated that I can use
    > the % as the default value for microsoft Access in an Asp.net page. It said to
    > use the following format.
    >
    > (IIf((Request.Form("txtCity") <> Nothing),
    > Request.Form("txtCity"), "")) + "%"
    >
    > Again, this format works great if I delete the "%" and put any default value
    > like "2" or something. The only thing that doesn't work is the % character!!!
    > I
    > just can't figure out why not. It's driving me crazy. Am I reading the
    > reference incorrectly? It shows the same syntax for the SQL statement I am
    > using with WHERE CategoryID = ? without any apostrophe or quotes.
    >
    > Here is the reference I am referring to:
    > [url]http://livedocs.macromedia.com/dreamweaver/mx2004/using/wwhelp/wwhimpl/common/[/url]
    > ht
    > ml/wwhelp.htm?context=Using_Dreamweaver&file=43_rad10 .htm
    >
    > Anyone have any other ideas? Feel free to say any solution you can think of
    > even if it sounds obvious. I am very inexperienced. Thanks!
    > James
    >
    Calvin Willman Guest

  8. #7

    Default Re: Default value for url parameter

    That's a good idea, but I still can't get it to work. Thanks for the help
    anyway. I'm sure there is some way to do it on the code side... I'll try to
    figure that out. I don't know asp very well but I've got to learn sometime!
    I'll post the solution when I figure it out.

    Thanks,
    James



    dischord13 Guest

  9. #8

    Default Re: Default value for url parameter

    I have a solution!! I just had to change the variable type to VarChar. I knew
    it was something obvious I was not doing. Wildcard characters will not work
    with integer variables. So now I can just click the build button for the
    variable and add the % sign as the defualt value.

    I had thought the variable type didn't matter becase in Access you can use the
    * for any type of field and it will show all records. But variable types are
    different than field types. Programming basics.... I'm learning.

    Thanks for the ideas everyone.

    James

    dischord13 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139