Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Autonumber issue with SQL to Access ODBC link

Author  Topic 

Kift
Starting Member

14 Posts

Posted - 2011-04-01 : 12:53:06
Hi all,

I have a problem with a table I have created. I have posted teh create script that comes from right click / edit incase there is an issue with that. The problem I have is that when I open access and use an ODBC link to pull the table in, all the fields act as expected except for the autonumber.

Everything else changes to 0 but the autonumber field stays blank and so when I submit the record it throws up an error. I can only assume that it is to do with how I have set up the field as access is throwing up a stored proceedure error. This was the only way I could think of to get access to pull the field through as an autonumber and NULL is not allowed in the field when it send it back for creating. I think thats where I'm going wrong. If anybody could please provide some help I'd be most greatful.

Using SQL2005 and Access 2003

Many thanks

Error message:
ODBC call failed
[Microsoft][ODBC SQL Server Driver][SQL Server]The EXCUTE permission was denied on the objects 'sp_execute', database 'mysqlsystemresource', schema 'sys' (#299)

Create script:
SETANSI_NULLSON
SETQUOTED_IDENTIFIERON
CREATETABLE [dbo].[Contacts_Database](
[ID] [int] IDENTITY(1,1)NOTNULL,
[Org_Code] [nvarchar](255)NULL,
[Person_Name] [nvarchar](255)NULL,
[Job_Role] [nvarchar](255)NULL,
[Organisation_name] [nvarchar](255)NULL,
[Em_address] [nvarchar](255)NULL,
[telephone_number] [nvarchar](255)NULL,
[DS_MH] [bit] NOTNULLCONSTRAINT [DF_Contacts_Database_DS_MH] DEFAULT 0,
[DS_IA] [bit] NOTNULLCONSTRAINT [DF_Contacts_Database_DS_IA] DEFAULT 0,
[DS_CN] [bit] NOTNULLCONSTRAINT [DF_Contacts_Database_DS_CN] DEFAULT 0,
[DS_COM] [bit] NOTNULLCONSTRAINT [DF_Contacts_Database_DS_COM] DEFAULT 0,
[CAT_IND] [bit] NOTNULLCONSTRAINT [DF_Contacts_Database_CAT_IND] DEFAULT 0,
[CAT_TRU] [bit] NOTNULLCONSTRAINT [DF_Contacts_Database_CAT_TRU] DEFAULT 0,
[CAT_COMM] [bit] NOTNULLCONSTRAINT [DF_Contacts_Database_CAT_COMM] DEFAULT 0,
[CAT_DH] [bit] NOTNULLCONSTRAINT [DF_Contacts_Database_CAT_DH] DEFAULT 0,
[CAT_CH] [bit] NOTNULLCONSTRAINT [DF_Contacts_Database_CAT_CH] DEFAULT 0,
[CAT_SY] [bit] NOTNULLCONSTRAINT [DF_Contacts_Database_CAT_SYS] DEFAULT 0,
[CAT_OTHER] [bit] NOTNULLCONSTRAINT [DF_Contacts_Database_CAT_OTHER] DEFAULT 0,
[ACTIVE_CONTACT] [bit] NOTNULLCONSTRAINT [DF_Contacts_Database_ACTIVE_CONTACT] DEFAULT 0,
[INACTIVE_CONTACT_DATE] [nvarchar](255)NULL
)ON [PRIMARY]


Kift
Starting Member

14 Posts

Posted - 2011-04-05 : 05:48:32
Hey all. Does any one have any idea as to what i'm doing wrong? I really don't know how to proceed as the autonumber is provide the id field required for the ODBC link for updating. Thankfully ths is still at the start of the project so the table can be deleted and recreated to remove any errors.

Many thanks
Go to Top of Page

McDebil
Starting Member

23 Posts

Posted - 2011-04-05 : 07:47:36
HI,

I allways use parameterized stored procedures for data manipulation from MS Access apps (with ADO)



McDebil
Go to Top of Page
   

- Advertisement -