Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,
I have a code that connects to the access using Microsoft.ACE.OLEDB.12.0; and gets the data and inserts into Sage.
The first field it just retrieves 6 characters instead of 7. The rest of the fields are ok.

I use this code:
strInvoice=rs.Fields("InvoiceNo")
When in the SQl server I checked for the length of InvoiceNo, it said 7.

Thanks
Sanaz
Posted
Comments
Valery Possoz 3-Sep-14 18:51pm    
Does the value that has 7 characters start with "0"....?
PhilLenoir 4-Sep-14 9:34am    
What is your data - give an example of the data that is being truncated.
What is the data type in SQL Server, char or varchar?
If the field is a char then it will be padded with spaces if actually shorter than 7.
What is the type of the recordset (DAO or ADO)? Access is often "helpful" and trims trailing spaces.
Did you check the value of strInvoice in debug? Use:
? "|" & strInvoice & "|"
to see if there are any leading or trailing spaces fetched into the variable; compare that to the original value (in SQL Server using SQL Management Studio, not Access)
sanazm 10-Sep-14 13:40pm    
Thanks for your reply. It is

Basically it is trying to get the tracking numbers from UPS access to Sage software.
The invoice numbers are 7 digit number, no space and they start with 0 but the code doesn't grab the last number. When I put "|" & strInvoice & "|" in front of MSgbox, it gave me just ||.
But it gets the whole trackingID.
Set cnnConnection = CreateObject("ADODB.Connection")
strDatasource="provider=Microsoft.ACE.OLEDB.12.0;

Thanks


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900