asp tutorials, asp.net tutorials, sample code, and Microsoft news from 15Seconds
Data Access  |   Troubleshooting  |   Security  |   Performance  |   ADSI  |   Upload  |   Email  |   Control Building  |   Component Building  |   Forms  |   XML  |   Web Services  |   ASP.NET  |   .NET Features  |   .NET 2.0  |   App Development  |   App Architecture  |   IIS  |   Wireless
 
Pioneering Active Server
 Power Search










Active News
15 Seconds Weekly Newsletter
• Complete Coverage
• Site Updates
• Upcoming Features

More Free Newsletters
Reference
News
Articles
Code Samples
Components
Tools
New
Free
Downloads
Vendors
FAQ
Feedback
Books
Links
DL Archives
Community
Messageboard
List Servers
Mailing List
WebHosts
Consultants
Tech Jobs
15 Seconds
Home
Site Map
Press
Legal
Privacy Policy
internet.commerce














internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

HardwareCentral
Compare products, prices, and stores at Hardware Central!

When you add a new record, several factors determine where it will be inserted. If you need to come back to this record later, save a bookmark to the current row. However, when you insert records into a table without an index against Microsoft SQL Server, you will not be able to get back to the newly inserted row after you move the current record pointer unless a Requery is performed.

However, if you are using SQL Server and one column has a IDENTITY value you can execute the below script to get the IDENTITY of the row, if the column is also a primary key then you can use the returned value to access the row again.

'A little code to Give Out the Right Cookie
UserId=Request.Cookies("USER")
' If there isn't a cookie then Get One From the SQL Server
if UserId = "" then
Set connOnline = Server.CreateObject("ADODB.Connection")
connOnline.Open "UserDatabase", "login", "password"
sql="INSERT INTO tblUser DEFAULT VALUES SELECT @@IDENTITY 'UserId'" Set RS = connOnline.Execute(sql)
NextRS=RS.NextRecordset
UserId=NextRS("UserId")
connOnline.Close
' Set Cookie
Response.Cookies("USER")=UserId
end if
Here is the SQL to create the Table in the UserDatabase
CREATE TABLE tblUser (UserId int IDENTITY NOT NULL PRIMARY KEY)




email this code sample to a colleague

Related Articles
Dec 10, 1996 - ODBC 3.0 Connection Pooling
This issue of 15 Seconds contain an example of how to create an ISAPI server extension in MSVC 4.2 with ODBC 3.0 connection pooling. There is also an evaluation of ODBC 3.0, OLEDB, ADO and DAO.
[Read This Article]  [Top]
May 31, 1997 - Connection Pooling with ASP
Connection pooling might be the easiest way to speed up your dynamic web pages reading from SQL Server. Unfortunately, connection pooling within is turned off by default in Active Server pages. Probably because connection pooling is rarely understood in its entirety. This issue discusses connection pooling with ASP, ISAPI, IDC, and Visual Basic applications. Included is a discussion about ODBC 3.0 and the newest bug fix for ODBC.
[Read This Article]  [Top]
Apr 15, 1998 - File Repository Weblication using IIS 4.0
In this article Amos El-Roy demonstrates how to create a file repository using ASP pages. A seamless approach that maximizes accessibility and lowers administrative overhead is illustrated in the article's example, which is available for download.
[Read This Article]  [Top]
Oct 21, 1999 - Updating Excel From the Web
Bill Jeffries's article on Excel's Web Query tool demonstrates how to update selected spreadsheet cells instantly over an HTTP connection.
[Read This Article]  [Top]
Nov 11, 1999 - Database-Driven WWW Help System
The help system presented in Vujosevic and Laberge's article is self contained and can be updated and altered without impacting the original Web application. Much like an online book, the help icon in the Web application dives into an application system for the help option. Each Web page has its own separate help page with a database that contains one row in a table for every calling Web page. Sample code is provided.
[Read This Article]  [Top]
Related Books
Working with Active Server Pages
Understanding ActiveX and OLE: A Guide for Developers and Managers
Professional Active Server Pages
Professional Visual C++ 5.0 ActiveX/COM Control Programming
Teach yourself Active Web Database Programming in 21 Days
Unlocking Active Server Pages
Active Server Pages for Dummies
Active Server Pages How-To : The Definitive Active Server Pages Problem-Solver
Active Server Pages Unleashed
Programming Active Server Pages
Teach Yourself Active Server Pages in 14 Days
The Active Server : A Developer's Guide Creating Dynamic Web Content
Active Server Pages Black Book
Professional Active Server Pages 2.0
Professional Asp and Rds Database Programming
Special Edition Using Active Server Pages
Microsoft® BackOffice® Resource Kit, Second Edition
Related Knowledge Base Articles
INFO: ODBC Connection Pooling and ADO
Q166886 - 1997.06.23
FIX: Repetitive Connect/Disconnect May Shut Dow...
Q164734 - 1997.06.23
INF: SQL Logs 17832 With Multiple TCP\IP Connec...
Q154628 - 1997.06.23
INF: How to Access SQL Server Within Active Ser...
Q169377 - 1997.06.23
INF: Frequently Asked Questions About ODBC Conn...
Q169470 - 1997.07.10
HOWTO: Redistributing ADO 1.0 or ADO/R 1.0 with...
Q168122 - 1997.08.09
HOWTO: Calling SQL Server Stored Procedures fro...
Q164485 - 1997.08.21
HOWTO: Determining How to Define a Stored Proce...
Q165156 - 1997.08.21
PRB: Accessing SQL Database Fails on Second Att...
Q166659 - 1997.09.06
INFO: Underlying OLE and OLEDB Provider Errors ...
Q168354 - 1997.09.23

Support the Active Server Industry



JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers