Professional Web Applications Themes

Passing ASP Variables - ASP Database

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 ...

  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. #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" <darrenwoodbreyhpfairfield.com> wrote in message
    news:uK7Ek4iIEHA.3128TK2MSFTNGP10.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

  3. #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

Similar Threads

  1. Passing Variables
    By LegeDoos in forum Macromedia Flash Data Integration
    Replies: 16
    Last Post: July 1st, 08:25 PM
  2. Passing variables from one swf to another
    By chintuChamp in forum Macromedia Flash Flashcom
    Replies: 1
    Last Post: October 20th, 02:48 PM
  3. Passing variables to ASP
    By jeskey in forum Macromedia Flash Data Integration
    Replies: 3
    Last Post: April 27th, 06:08 AM
  4. Passing Variables from swf to swf
    By vin-E in forum Macromedia Flash Actionscript
    Replies: 1
    Last Post: January 19th, 09:36 PM
  5. variables, passing again to another.
    By Louie Miranda in forum PHP Development
    Replies: 0
    Last Post: September 25th, 07:46 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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