|
-
Apr 5th, 2001, 06:28 AM
#1
Thread Starter
Lively Member
Hi,
I'm writing an application in VB where I have to create a new Access table at a run time. Every time my program adds a new record I need to generate a new primary key value. I tryed to use AutoNumber field type but vb doesn't seems to have it (or it could not find it. When I tryed to return the type of the AutoNumber field it returned 4 which is a Number type).
Is there anything else that could be done apart from DBGUID type?
Thank you
-
Apr 5th, 2001, 07:48 AM
#2
Dim m_conn As ADODB.Connection
Set m_conn = New ADODB.Connection
m_conn.ConnectionString = "Your connection"
Dim strSQL As String
strSQL = "Create Table YOUR_TABLE (FIRST_COL int Not Null, "
strSQL = strSQL & "SECOND_COL int Not Null, OTHER_COL int Not Null, "
strSQL = strSQL & "Last_COL datetime Null)"
m_conn.Open
m_conn.BeginTrans
m_conn.Execute strSQL
strSQL = "ALter Table YOUR_TABLE Add Constraint PK_FIRTS_COL Primary Key" & _
" Nonclustered ( FIRST_COL )"
m_conn.Execute strSQL
m_conn.CommitTrans
m_conn.Close
Set m_conn = Nothing
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|