Solved

Visual Basic and access autonumber

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
Familiarize people with the process of utilizing SQL Server stored procedures 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 Micr…
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.

790 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