473,804 Members | 3,412 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ADOX/Jet database column autoincrement assignment problem

I am trying to create an access database within Net 2003 using the ADOX
library which works fine except when I try to add the AutoIncrement property
to the ContactId column.

I am experiencing a Property 'item' is ReadOnly error within the below line

.Columns("Conta ctId").Properti es("AutoIncreme nt") = True

Am I missing a reference or what am I doing wrong?????

Following is the sample code I am using (ex MSDN) as the starting point.

'Project references
'Microsoft ADO Ext. 2.8 for DDL and Security
'Microsoft ActiveX Data Accss Objects 2.8 Library
Imports ADOX
Imports ADOX.DataTypeEn um

Sub Main()

Dim cnn As New ADODB.Connectio n
Dim cat As New ADOX.Catalog
Dim tbl As New ADOX.Table

cnn.Open "Provider='Micr osoft.Jet.OLEDB .4.0';" & _
"Data Source='Northwi nd.mdb';"
cat.ActiveConne ction = cnn

With tbl
.Name = "MyContacts "
.ParentCatalog = cat
' Create fields and append them to the new Table object.
.Columns.Append "ContactId" , adInteger
' Make the ContactId column and auto incrementing column
.Columns("Conta ctId").Properti es("AutoIncreme nt") = True
.Columns.Append "CustomerID ", adVarWChar
.Columns.Append "FirstName" , adVarWChar
.Columns.Append "LastName", adVarWChar
.Columns.Append "Phone", adVarWChar, 20
.Columns.Append "Notes", adLongVarWChar
End With
cat.Tables.Appe nd tbl
'Clean up
cnn.Close
Set cat = Nothing
Set tbl = Nothing
Set cnn = Nothing
End Sub

Nov 21 '05 #1
6 9181
Try changing it to this:
..Columns("Cont actId").Propert ies("AutoIncrem ent").Value = True

I had the same error until I did it this way.

james


"Michael" <mc********@hou ston.rr.com> wrote in message news:Pr******** *********@fe2.t exas.rr.com...
I am trying to create an access database within Net 2003 using the ADOX library which works fine except when I try to add the
AutoIncremen t property to the ContactId column.

I am experiencing a Property 'item' is ReadOnly error within the below line

.Columns("Conta ctId").Properti es("AutoIncreme nt") = True

Am I missing a reference or what am I doing wrong?????

Following is the sample code I am using (ex MSDN) as the starting point.

'Project references
'Microsoft ADO Ext. 2.8 for DDL and Security
'Microsoft ActiveX Data Accss Objects 2.8 Library
Imports ADOX
Imports ADOX.DataTypeEn um

Sub Main()

Dim cnn As New ADODB.Connectio n
Dim cat As New ADOX.Catalog
Dim tbl As New ADOX.Table

cnn.Open "Provider='Micr osoft.Jet.OLEDB .4.0';" & _
"Data Source='Northwi nd.mdb';"
cat.ActiveConne ction = cnn

With tbl
.Name = "MyContacts "
.ParentCatalog = cat
' Create fields and append them to the new Table object.
.Columns.Append "ContactId" , adInteger
' Make the ContactId column and auto incrementing column
.Columns("Conta ctId").Properti es("AutoIncreme nt") = True
.Columns.Append "CustomerID ", adVarWChar
.Columns.Append "FirstName" , adVarWChar
.Columns.Append "LastName", adVarWChar
.Columns.Append "Phone", adVarWChar, 20
.Columns.Append "Notes", adLongVarWChar
End With
cat.Tables.Appe nd tbl
'Clean up
cnn.Close
Set cat = Nothing
Set tbl = Nothing
Set cnn = Nothing
End Sub

Nov 21 '05 #2
Try changing it to this:
..Columns("Cont actId").Propert ies("AutoIncrem ent").Value = True

I had the same error until I did it this way.

james


"Michael" <mc********@hou ston.rr.com> wrote in message news:Pr******** *********@fe2.t exas.rr.com...
I am trying to create an access database within Net 2003 using the ADOX library which works fine except when I try to add the
AutoIncremen t property to the ContactId column.

I am experiencing a Property 'item' is ReadOnly error within the below line

.Columns("Conta ctId").Properti es("AutoIncreme nt") = True

Am I missing a reference or what am I doing wrong?????

Following is the sample code I am using (ex MSDN) as the starting point.

'Project references
'Microsoft ADO Ext. 2.8 for DDL and Security
'Microsoft ActiveX Data Accss Objects 2.8 Library
Imports ADOX
Imports ADOX.DataTypeEn um

Sub Main()

Dim cnn As New ADODB.Connectio n
Dim cat As New ADOX.Catalog
Dim tbl As New ADOX.Table

cnn.Open "Provider='Micr osoft.Jet.OLEDB .4.0';" & _
"Data Source='Northwi nd.mdb';"
cat.ActiveConne ction = cnn

With tbl
.Name = "MyContacts "
.ParentCatalog = cat
' Create fields and append them to the new Table object.
.Columns.Append "ContactId" , adInteger
' Make the ContactId column and auto incrementing column
.Columns("Conta ctId").Properti es("AutoIncreme nt") = True
.Columns.Append "CustomerID ", adVarWChar
.Columns.Append "FirstName" , adVarWChar
.Columns.Append "LastName", adVarWChar
.Columns.Append "Phone", adVarWChar, 20
.Columns.Append "Notes", adLongVarWChar
End With
cat.Tables.Appe nd tbl
'Clean up
cnn.Close
Set cat = Nothing
Set tbl = Nothing
Set cnn = Nothing
End Sub

Nov 21 '05 #3
James

The fix worked - thanks

Mike

"james" <jjames700ReMoV eMe at earthlink dot net> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
Try changing it to this:
.Columns("Conta ctId").Properti es("AutoIncreme nt").Value = True

I had the same error until I did it this way.

james


"Michael" <mc********@hou ston.rr.com> wrote in message
news:Pr******** *********@fe2.t exas.rr.com...
I am trying to create an access database within Net 2003 using the ADOX
library which works fine except when I try to add the AutoIncrement
property to the ContactId column.

I am experiencing a Property 'item' is ReadOnly error within the below
line

.Columns("Conta ctId").Properti es("AutoIncreme nt") = True

Am I missing a reference or what am I doing wrong?????

Following is the sample code I am using (ex MSDN) as the starting point.

'Project references
'Microsoft ADO Ext. 2.8 for DDL and Security
'Microsoft ActiveX Data Accss Objects 2.8 Library
Imports ADOX
Imports ADOX.DataTypeEn um

Sub Main()

Dim cnn As New ADODB.Connectio n
Dim cat As New ADOX.Catalog
Dim tbl As New ADOX.Table

cnn.Open "Provider='Micr osoft.Jet.OLEDB .4.0';" & _
"Data Source='Northwi nd.mdb';"
cat.ActiveConne ction = cnn

With tbl
.Name = "MyContacts "
.ParentCatalog = cat
' Create fields and append them to the new Table object.
.Columns.Append "ContactId" , adInteger
' Make the ContactId column and auto incrementing column
.Columns("Conta ctId").Properti es("AutoIncreme nt") = True
.Columns.Append "CustomerID ", adVarWChar
.Columns.Append "FirstName" , adVarWChar
.Columns.Append "LastName", adVarWChar
.Columns.Append "Phone", adVarWChar, 20
.Columns.Append "Notes", adLongVarWChar
End With
cat.Tables.Appe nd tbl
'Clean up
cnn.Close
Set cat = Nothing
Set tbl = Nothing
Set cnn = Nothing
End Sub


Nov 21 '05 #4
James

The fix worked - thanks

Mike

"james" <jjames700ReMoV eMe at earthlink dot net> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
Try changing it to this:
.Columns("Conta ctId").Properti es("AutoIncreme nt").Value = True

I had the same error until I did it this way.

james


"Michael" <mc********@hou ston.rr.com> wrote in message
news:Pr******** *********@fe2.t exas.rr.com...
I am trying to create an access database within Net 2003 using the ADOX
library which works fine except when I try to add the AutoIncrement
property to the ContactId column.

I am experiencing a Property 'item' is ReadOnly error within the below
line

.Columns("Conta ctId").Properti es("AutoIncreme nt") = True

Am I missing a reference or what am I doing wrong?????

Following is the sample code I am using (ex MSDN) as the starting point.

'Project references
'Microsoft ADO Ext. 2.8 for DDL and Security
'Microsoft ActiveX Data Accss Objects 2.8 Library
Imports ADOX
Imports ADOX.DataTypeEn um

Sub Main()

Dim cnn As New ADODB.Connectio n
Dim cat As New ADOX.Catalog
Dim tbl As New ADOX.Table

cnn.Open "Provider='Micr osoft.Jet.OLEDB .4.0';" & _
"Data Source='Northwi nd.mdb';"
cat.ActiveConne ction = cnn

With tbl
.Name = "MyContacts "
.ParentCatalog = cat
' Create fields and append them to the new Table object.
.Columns.Append "ContactId" , adInteger
' Make the ContactId column and auto incrementing column
.Columns("Conta ctId").Properti es("AutoIncreme nt") = True
.Columns.Append "CustomerID ", adVarWChar
.Columns.Append "FirstName" , adVarWChar
.Columns.Append "LastName", adVarWChar
.Columns.Append "Phone", adVarWChar, 20
.Columns.Append "Notes", adLongVarWChar
End With
cat.Tables.Appe nd tbl
'Clean up
cnn.Close
Set cat = Nothing
Set tbl = Nothing
Set cnn = Nothing
End Sub


Nov 21 '05 #5
Glad it worked for you.
james

"Michael" <mc********@hou ston.rr.com> wrote in message news:ue******** **********@fe2. texas.rr.com...
James

The fix worked - thanks

Mike

"james" <jjames700ReMoV eMe at earthlink dot net> wrote in message news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
Try changing it to this:
.Columns("Conta ctId").Properti es("AutoIncreme nt").Value = True

I had the same error until I did it this way.

james

Nov 21 '05 #6
Glad it worked for you.
james

"Michael" <mc********@hou ston.rr.com> wrote in message news:ue******** **********@fe2. texas.rr.com...
James

The fix worked - thanks

Mike

"james" <jjames700ReMoV eMe at earthlink dot net> wrote in message news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
Try changing it to this:
.Columns("Conta ctId").Properti es("AutoIncreme nt").Value = True

I had the same error until I did it this way.

james

Nov 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
2328
by: Tamblyne | last post by:
This problem has got to have a simple solution and I can't be the first person who has ever handled it. Perhaps Google is no help because I'm not using the right terms? (I did find one post on-point, but no one responded to it.) I have a two column layout with a header and a footer. If the "content" is longer than the "navigation", there is no problem. However, if the content is shorter than the navigation, the navigation menus...
0
368
by: Ivaylo | last post by:
I use OleDbAdapter to fill my dataset from Access database and tables with autoincrement id columns.Also i created xsd schema for my dataset The problem is that the dataset automatically add neu unique ID which is not correspond to realy added record ID in the database For exp. in database i have ID Name Titl 10 john some tex 12 peter ....... ds.Table1Row newrow=ds.Table1.NewTable1Row(
0
428
by: Michael | last post by:
I am trying to create an access database within Net 2003 using the ADOX library which works fine except when I try to add the AutoIncrement property to the ContactId column. I am experiencing a Property 'item' is ReadOnly error within the below line .Columns("ContactId").Properties("AutoIncrement") = True Am I missing a reference or what am I doing wrong?????
1
2137
by: Dan Manes | last post by:
Wondering what other people do about this issue... You're writing a web app in asp.net that requires user input. Data will be stored in SQL Server Express database. You want to make sure data does not exceed maximum length for database column. For example, "User Name" column in database is set to varchar(30), so you would like to also set your textbox to a MaxLength of 30. To guard against hackers, etc., you also want to set up a...
3
4178
by: Bren | last post by:
Hi All VS2005 Gridview control with vb I am populating a gridview of company staff. One of the columns is a hyperlink to a SMS texting facility I have so secrataries can text the managers etc. i.e Secratary loads the page on the intranet, finds the manager they want to contact, clicks on the "SMS" hyperlink and is taken to the SMS page to fill out the message and send it to the manager.
1
1704
by: adnanahmed714 | last post by:
hi all i want to calculate the Standered deviation of last 20 values in the database column,how can i do it using DTDEV function of SQL. PLZZZZZZZZZZZZZZZZ Reply me Thanks in advance to all.
1
2135
by: adnanahmed714 | last post by:
Hi All i Want to calculate STDEV of last 20 values in the database Column,using VB Want help on the syntax of the statment Thanks in advance
1
2516
by: momo | last post by:
Hi everybody, I have to implement a routing and wavelength assignment problem (RWA) for a given optical network. I ve implemented the network graph in C using linked list. the shortest-path routing problem is done. does anyone have any idea how to implement in C the assignement problem? or have the code? the algorithm should assign wavelengths to incoming calls until capacity is reached over a given path, hence the call is rejected. ...
2
2978
by: Chris | last post by:
I have a database column that stores a comma delimited list of foreign keys. Would someone show me how to do a join using the values from a list stored within a record? For example, a record in tbl_cds.genre_id might have a value of "2, 5, 6" corresponding to genre_ids 2 , 5 and 6. I want to join tbl_cds.genre_id to tbl_genre.genre_id using the values in that data field. It seems I need a loop like this:
0
9707
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9585
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10323
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9161
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7622
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6856
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3823
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2997
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.