?
Solved

Trim Character from ComboBox text with source as Datatable?

Posted on 2006-05-20
3
Medium Priority
?
267 Views
Last Modified: 2006-11-18
Im using a datatable as the source of my combobox. Code looks like this:

     With ComboBox1
            .DisplayMember = "Account #"
            .ValueMember = "ID"
            .DataSource = MyDataTable
        End With

I want to trim the first character from all the "Account #"s.  My account numbers look like this S0000000001 , I need to get rid of the S. I have tried variations of Trim and Substring(1, 10) on both the combobox and the datatable with no luck. How can I do this ? Thanks for any help you can provide!

0
Comment
Question by:kasowitz
  • 2
3 Comments
 
LVL 28

Accepted Solution

by:
strickdd earned 1000 total points
ID: 16726964
I'm assuming you're doing a select statement on the DB, whether it's in a stored procedure or in the code itself, so you should probably try:

SELECT SUBSTRING([Account #], 2,11), ID FROM MyDataTable

This will select the column "Account #" from the table and only return the values from the second digit from the left to the last digit. This assumes that your account numbers are all 11 characters long.
0
 

Author Comment

by:kasowitz
ID: 16727018
How would I implement that ?

I am doing a select statement on a SQL DB.  "SELECT [Account #] FROM TABLE WHERE [Account #] LIKE 'S%' "   Then using the DataAdapter I am filling the DataTable. From the DataTable I am populating the ComboBox.

So Im not sure how to do what you just said?
0
 

Author Comment

by:kasowitz
ID: 16729006
Sorry, I didnt realize I could use the SUBSTRING command in the actual SQL Statement.

SELECT SUBSTRING([Account #], 2,11) as ID FROM TABLE WHERE [Account #] LIKE 'S%'  

works perfect..thanks :)
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month15 days, 21 hours left to enroll

850 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