Passing ASP Variables

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Passing ASP Variables

    I have a form that submits to a SQL database. The table in SQL uses an
    identity field for the primary key called "entry". This is so I can get the
    primary key to auto-increment. The form posts to a page with a SQL insert
    statement. On this page I run a select statement to retrieve the entry
    variable.

    declare @entry int
    set @entry = (select scope_identity())
    SELECT entry
    FROM wo_main
    WHERE (entry = @entry)

    This will display the the primary key that was just entered. I now want to
    use response.redirect or something else to redirect to a links page
    immediately. The problem is getting the @entry variable to pass to the
    links page.

    I can get this to work if the origianl form is actually submitting the
    primary key field using a respose.write but can not figure out how to do it
    with the primary key being auto-assigned. Any help would be very much
    appreciated. Thanks

    Darren
    MCP


    Darren Woodbrey Guest

  2. Similar Questions and Discussions

    1. Passing Variables
      Hi there, I just managed to install apache2 webserver with php 4.3.8. I'm developing some php files. Previously I used an external webserver but...
    2. Passing variables from one swf to another
      I am facing problem to pass variable from one swf to another. I am using loadMovie to load another swf. how can I pass a variable value to another...
    3. Passing variables to ASP
      I am trying to pass variables from a contact form to an ASP page to be written to a database. I have input fields on the contact page and have given...
    4. Passing Variables from swf to swf
      Is there a good tutorial to do this? I am building greeting cards - I am loading a seperate file before I print them out so I am trying to pass...
    5. variables, passing again to another.
      if ($psi_shipping_addtnl_info != '') { echo '<< NO USER INPUT >>'; } Im catching a _POST variable from a form, now i wonder im filtering it out...
  3. #2

    Default Re: Passing ASP Variables

    Use a stored procedure as so:


    CREATE PROC something (@yourData varchar(50)) AS
    SET NOCOUNT ON
    INSERT INTO wo_main (columnName) VALUES (@yourData)
    SELECT SCOPE_IDENTIY()
    GO


    <%
    sValue = "something"
    Set rs = yourADOObject.Execute("EXEC something '" & sValue & "')
    iNewIdentity = rs.Fields.Item(0).Value
    rs.Close : Set rs = Nothing
    yourADOObject.Close : Set yourADOObject = Nothing
    %>

    Another option is to set your scope_identity to be an output parameter and
    use a command object to get it. Some would argue that this is better. I
    believe you can read more about that here.
    [url]http://www.aspfaq.com/show.asp?id=2201[/url] I personally don't, and I don't have
    any excuse or reason that is valid!

    Ooh, also see here: [url]http://www.aspfaq.com/show.asp?id=2174[/url]

    Ray at work




    "Darren Woodbrey" <darrenwoodbrey@hpfairfield.com> wrote in message
    news:uK7Ek4iIEHA.3128@TK2MSFTNGP10.phx.gbl...
    > I have a form that submits to a SQL database. The table in SQL uses an
    > identity field for the primary key called "entry". This is so I can get
    the
    > primary key to auto-increment. The form posts to a page with a SQL insert
    > statement. On this page I run a select statement to retrieve the entry
    > variable.
    >
    > declare @entry int
    > set @entry = (select scope_identity())
    > SELECT entry
    > FROM wo_main
    > WHERE (entry = @entry)
    >
    > This will display the the primary key that was just entered. I now want
    to
    > use response.redirect or something else to redirect to a links page
    > immediately. The problem is getting the @entry variable to pass to the
    > links page.
    >
    > I can get this to work if the origianl form is actually submitting the
    > primary key field using a respose.write but can not figure out how to do
    it
    > with the primary key being auto-assigned. Any help would be very much
    > appreciated. Thanks
    >
    > Darren
    > MCP
    >
    >

    Ray at Guest

  4. #3

    Default Re: Passing ASP Variables

    4GuysFromRolla.com : ASP FAQS : Databases, General
    How do I get the record number of a just added record, using an Access
    database table? by Bill Wilkinson - 11/3/2000
    [url]http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=79[/url]

    ADO FAQ - Q9) How do I get the AutoNumber (or Identity) for a newly
    inserted record?
    [url]http://www.able-consulting.com/ADO_Faq.htm#Q9[/url]

    INFO: Identity and Auto-Increment Fields in ADO 2.1 and Beyond
    [url]http://support.microsoft.com/support/kb/articles/q233/2/99.ASP[/url]

    INFO: Identity (AutoIncrement) Columns in ADO or RDS
    [url]http://support.microsoft.com/support/kb/articles/q195/9/10.asp[/url]

    User Tips: Getting the ID of the Just Inserted Database Record by Dan H.
    - 12/26/2000
    [url]http://www.4guysfromrolla.com/webtech/tips/t122600-1.shtml[/url]

    Best regards,
    J. Paul Schmidt, Freelance ASP Web Consultant
    [url]http://www.Bullschmidt.com[/url]
    ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Bullschmidt 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