Solved

Visual Basic and access autonumber

Posted on 2014-02-16
4
1,102 Views
Last Modified: 2014-02-18
Hello,

Can anyone help me with an issue with auto number field in an access database. I get an error of data type mismatch in visual basic.net when I use the Intert Into.
0
Comment
Question by:lincstech
  • 2
4 Comments
 
LVL 27

Expert Comment

by:MacroShadow
ID: 39862580
Don't explicitly insert the autonumber, as the records are inserted they are assigned numbers by access (hence the name AUTOnumber). If that doesn't help, I'll have to see your code.
0
 
LVL 29

Accepted Solution

by:
gowflow earned 500 total points
ID: 39863029
yes if you include in your sql in insert into the field that is autonumber you will get an error.
if you have say 5 fields
Field1
Field2
Field3
Field4
ID      Autonumber

you do an insert of Field1,Field2,Field3,Field4
and they will automatically take correct numbering after the last item in your database and no error

gowflow
0
 
LVL 35

Expert Comment

by:PatHartman
ID: 39863450
You can actually supply a value for the autonumber when running an Append query.  Otherwise, conversions would be even more of a nightmare than they already are.

Except for a conversion, you would never want to supply a value for the autonumber.  That is the point.  Access (actually Jet or ACE) provides the value automatically.

You are not running the query in Access though so this isn't really an Access question.  It is a question regarding the database engines Jet or ACE depending on whether you are using an .mdb or .accdb.  

I don't know if you can provide a value for the autonumber when you are using ADO.Net.  You probably just want to remove the autonumber column from your insert statement since I doubt you are doing a conversion.
0
 
LVL 27

Expert Comment

by:MacroShadow
ID: 39866992
Isn't that what I wrote?
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains all about SQL Server Piecemeal Restore with examples in step by step manner.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

770 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