Solved

auto-generated primary key in sql 6.5

Posted on 1998-07-31
2
165 Views
Last Modified: 2010-08-05
Question :
1. How to create an auto-generated primary Key in SQL 6.5. (I notice it can be done in Access database).

2. Why 'Begin Transaction' query cannot be executed thru pass-thru command in Jet Database.
e.g : dbDatabase.Execute "Begin Transaction"  -> cause error : cannot execute query.

thansk
0
Comment
Question by:asiasoft
2 Comments
 
LVL 3

Accepted Solution

by:
CesarGon earned 50 total points
ID: 1467335
1. Set the field you want to be a auto-generated primary key as "identity" field. You can do it in the Enterprise Manager.

2. You cannot execute just a "BEGIN TRAN" in a statement; you must use dbDatabase.BeginTrans or else pack the begin-update-commit/rollback in a single statement:

  Dim strSql As String
  strSql = "BEGIN TRAN" & vbCrLf
  strSql = strSql & "DELETE FROM Computers" & vbCrLf
  strSql = strSql & "COMMIT TRANS"
  dbDatabase.Execute strSql

That works!.

Regards,
César.
0
 

Author Comment

by:asiasoft
ID: 1467336
thanks Cesar
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now