Solved

Visual Basic and access autonumber

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

Expert Comment

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

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

This article describes some very basic things about SQL Server filegroups.
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

863 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

19 Experts available now in Live!

Get 1:1 Help Now