Kevin McNeish Blog

All things iOS, Kindle and .NET

Recent Posts

Tags

News

  • First books in my new book series, "iOS App Development for Non-Programmers" are now available! iBookStore: http://itunes.apple.com/us/book/book-1-diving-in-ios-app-development/id558788074?mt=11 Amazon: http://www.amazon.com/dp/B0097N8XBE Amazon: http://www.amazon.com/dp/B0099RQGMQ

Community

Email Notifications

Archives

Handling Trailing Spaces with VFP Data and ADO.NET

When working with Visual FoxPro data in ADO.NET, you may be surprised to see trailing spaces at the end of your character data. Visual FoxPro automatically trims these trailing spaces in BROWSE windows and when binding to user interface controls, but .NET does not.

To address this issue, you can change your character fields to varchar fields (introduced in VFP 9.0). You can then write a quick utility to remove the trailing spaces from the character data.

If you can't remove the extra spaces due to requirements in your Visual FoxPro applications that are accessing the same data, you can remove the spaces programmatically in your .NET applications by adding RTRIM() commands to your ADO.NET SELECT statements. For example:

SELECT employeeid, lastname, RTRIM(firstname) as FirstName, title, titleofcourtesy, birthdate, hiredate, address, city, region, postalcode, country, homephone, extension, photo, notes, reportsto FROM Employees

Best Regards,
Kevin McNeish
Chief Architect MM .NET Application Framework
www.oakleafsd.com

 

Comments

Janos said:

Hi,

thanks for this tipp, this is exatly my problem, but your solution just dosn't work for me. Not with RTRIM, not with ALLTRIM, the trailing spaces does not go away.

# November 19, 2011 9:52 AM
Leave a Comment

(required) 

(required) 

(optional)
 

(required) 

If you can't read this number refresh your screen
Enter the numbers above: