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

PreviousNext

 

email this FAQ to a colleague

Q: If I add a new record to my database, how do I keep track of where it gets inserted?

A: 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)

- Wayne Berry

Articles
Sep 15, 2005 - Building an Image Keyword System
Unlike text-based file formats image files aren't made up of words, which makes searching for an image file by keyword difficult. Instead of being able to simply open the file to see what it contains, we're stuck looking at the text around it and other metadata to determine the image's meaning. In this article, Ziran Sun shows you how to build a simple database-based image keyword system that allows you to associate keywords with images and use these keywords to make finding images easier.
[Read This Article]  [Top]
Apr 7, 2005 - A Step-by-Step Guide To Using MySQL with ASP.NET - Part 2
In the second part of of his article on using MySQL with ASP.NET, Ziran Sun covers how to add a new MySQL user to the database server, assign the user the appropriate permissions, connect to the database, and build a simple ASP.NET page to perform a query.
[Read This Article]  [Top]
Feb 10, 2005 - A Step-by-Step Guide To Using MySQL with ASP.NET - Part 1
Back in the days of classic ASP, if you were building a database-driven web site, your choice was either to invest a lot of money to get a copy of Microsoft SQL Server (or some other enterprise-ready database) or invest a lot of time finding a way to deal with the performance and scalability limitations of Microsoft Access. Luckily these days there's another viable alternative: MySQL.
[Read This Article]  [Top]
Jan 27, 2005 - Moving a Database from SQL Server 7.0 to SQL Server 2000
Moving or copying a SQL Server database from one machine to another requires a lot of preparation in order to ensure a smooth transfer. In this article, Dina Fleet Berry examines the different methods and highlights the different issues associated with each of them.
[Read This Article]  [Top]
Jan 6, 2005 - Debugging a SQL Stored Procedure from inside SQL Server 2000 Query Analyzer
There are many times when using SQL Server 2000 Query Analyzer to debug SQL statements is a better choice than debugging in Visual Studio .NET. In this article, Dina Fleet Berry explains why and walks you through the debugging process step-by step.
[Read This Article]  [Top]

Books
Working with Active Server Pages
Michael Corning, Steve Elfanbaum, David Melnick
Teach yourself Active Web Database Programming ...
Dina Fleet, Matt Warren, Joyce Chen, Alexander Stojanovic

Code Samples
Creating a Unique Cookie with SQL Server
Using File DSNs
Connecting Database on the Fly
Number of Recordset(s) returned by a query or stored procedure
Making Your SQL Universal

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


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