0

I am presently working on an application for a fictive taxi company, and I have to record each new customer with a customerID set as AutoNumber with a specific format:

Field size : Long integer
New Values : Increment
Format  : \C00
Indexed : Yes(No Duplicate)
Text Align : General

Below is an example of how it appears in the database:

IdClient    Nom Prenom  Adresse TelNo
C002    Smith   Jackson Port-Louis  03546649

My VB.NET Form linked to my database does not show the same format, for instance, on the example above, in the 'IdClient' field it would show '2', completely ignoring the format for the field.

I use this connection "Provider=Microsoft.ACE.OLEDB.12.0;"

 Public DBDA As OleDbDataAdapter
 Public DBDT As DataTable
 DBDT = New DataTable
 DBDA = New OleDbDataAdapter(DBCmd)
 RecordCount = DBDA.Fill(DBDT)

and to pull the data to my datagridView

DgvClient.DataSource = Access.DBDT

I tried to look for a solution and found https://social.msdn.microsoft.com/Forums/vstudio/en-US/bad5f735-438b-4203-983f-a9e2ba06cb96/inserting-records-into-ms-access-where-there-is-an-autonumber-for-a-primary-key?forum=vbgeneral but it doesn't seem to fix my issues. Do I have to append the format to each data pulled from the 'IdClient' Column before it shows in the datagridview? Is there a way to keep the format when pulling the data from MS Access?

  • 1
    The data stored in Access doesn't actually have that form. Access just displays it that way in the Access UI. You would have to do the same in your own UI. The alternative would be to add an extra column to your table that uses an expression to generate data in that format. Querying that column would actually return data in that format. – jmcilhinney Apr 23 '18 at 08:51
  • @jmcilhinney Thank you for the quick answer, I will test that and feedback here. – LaureLazard Apr 24 '18 at 12:06

0 Answers0