Solved

Visual Basic and access autonumber

Posted on 2014-02-16
4
1,077 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 26

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 34

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 26

Expert Comment

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

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

746 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

11 Experts available now in Live!

Get 1:1 Help Now