Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 30th, 2007, 12:38 AM
Authorized User
 
Join Date: Aug 2007
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default Generating auto-ids using asp and sql

Well..m working on a project using asp as front-end and Sql as back-end.Now the proeblem is that I have to generate Company-id and then the employee-id automatically...So that each time a company details are filled in, they shud be assigned a company-id and then when the employee details wud be filled in, each employee of the company shud again be given an employee-id.

One more problem is there...m passing on company-id from my firstpage to next pages thru querystring method..but its not working...how to do that :(

 
Old August 30th, 2007, 01:20 AM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

How do I do this - In design view (inside Enterprise Manager):

> Place a field (I would name it ID) in the company and employee tables
> set the identity of this field to Yes
> make it a primary key

Now every time you insert a record this field will be populated automatically with the next sequential number. NOTE: You do not need to address this field in your insert statement - As mentioned it will populate its self.

I would pass the company ID in a session variable. IMO passing this via a QS is the next best option. Any how to assign it to a QS value for a new user:

> fill in registration form
> submit the form
> insert record
> get the top most ID (this is the record you have just inserted). Lets say your recordset is called RS.

response.redirect("somPageName.asp?cID=" & rs("id") & "")

Now on the page you send them to (somePageName.asp I have used above) do the following:

<%= trim(request.querystring("cID")) %>

Wind is your friend
Matt
 
Old August 30th, 2007, 01:57 AM
Authorized User
 
Join Date: Aug 2007
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'll again trouble u by my questions MAT :) Well..I wont be discussing this identity problem for sometime...what I want to know is how to assign variable's value(id in my case) to session variable? I wrote this way on my first page--

session("id")=request.form("company_id")

and when m tryin to print the variable on next page by writing-

response.write session("id")


then its not gettin printed on my page... how to use session variable??
I've also made a global.asa file in my root directory ...do i need to do nethin else in order to use session variable?






Similar Threads
Thread Thread Starter Forum Replies Last Post
Using sql express for generating the report !! alam1 Reporting Services 0 May 26th, 2007 11:11 PM
Auto generate IDs in MS SQL... Lynn SQL Server 2000 8 November 28th, 2006 10:00 AM
asp/sql auto email on specified date keyvanjan Classic ASP Professional 2 March 5th, 2006 09:14 PM
asp/sql auto email on specified date keyvanjan Classic ASP Databases 0 February 26th, 2006 03:34 AM
generating xml files from sql queries Thebravehearth XML 0 November 1st, 2004 11:41 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.