Click here to Skip to main content
15,886,689 members
Articles / Programming Languages / T-SQL

How to remove white space in VB.NET

Rate me:
Please Sign up or sign in to vote.
2.33/5 (3 votes)
29 Jan 2013CPOL 19.4K  
In the following code all the subject codes are read by SQLDataReader rd. How do I make the DataReader read the subject code of only the selected subject regardless of whether the subject name contain white space or not such as Biology, English Language, Principles of Cost Accounting, etc? ...

Alternatives

Members may post updates or alternatives to this current article in order to show different approaches or add new features.

Please Sign up or sign in to vote.
28 Jan 2013Adam R Harris
RTRIM[^] And/Or LTRIM[^] in your SQL statement.Alternatively you could use String.Trim[^]
Please Sign up or sign in to vote.
29 Jan 2013Mike Meinz
1. Do not remove spaces from the subname variable during the Form Load event.subname = Module1.sname2. String.Format("%{0}%", "") creates a string parameter that contains %%. Used with the LIKE operator, it will match everything in the database. Please change that line of code to...

License

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


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions