Solved

part of text filter

Posted on 2014-10-12
2
97 Views
Last Modified: 2014-10-16
Hi Expert
I am trying to get data form a table using following code, it does not wotk

     Dim datemp As New SqlDataAdapter(" select * FROM customer ", conexp)
        datemp.Fill(dstemp, "customer")
        dttemp = dstemp.Tables("customer")
        Dim dv As New DataView

        dv = New DataView(dstemp.Tables(0), " Microsoft.VisualBasic.Left(customer.ccode, 3) ' ='FMS'", "", DataViewRowState.CurrentRows)
        DataGridView1.DataSource = dv

please help
0
Comment
Question by:b001
2 Comments
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 500 total points
Comment Utility
The selection filter is not supposed to use VB.NET code, you can use some SQL-like functions, see explanation here: http://msdn.microsoft.com/en-us/library/system.data.datacolumn.expression(v=vs.100).aspx (under Expression Syntax).

In this case you could use:
dv = New DataView(dttemp, "Substring(ccode, 1, 3)='FMS'", "", DataViewRowState.CurrentRows)

Open in new window

0
 
LVL 40

Expert Comment

by:Jacques Bourgeois (James Burger)
Comment Utility
I would expand on Robert's answer.

Shy away from anything that comes from the Microsoft.VisualBasic namespace. This has been designed to enable conversions from VB6 to VB.NET (as bad as they are), and to help amateur programmers moving from classic to .NET VB programming.

Learn to use the equivalent methods in the framework instead. They are often easier to use, but the most important reason is that they usually offer more features, such as text alignment on the MessageBox.Show method that replaces MsgBox. They also prepare you to switch to another language if you ever need to, because all the .NET languages use those methods, while only VB uses the Microsoft.VisualBasic methods.

When you do not find what is the equivalent in .NET of a VB6 method or feature, simply ask here. You can also give a look a document I built for my own use while I was making the transition 14 years ago. It far from being complete, but it can help you starting. Disregard the French introduction, the listing of equivalences is understandable for anybody who know VB.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

763 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

Need Help in Real-Time?

Connect with top rated Experts

5 Experts available now in Live!

Get 1:1 Help Now