Solved

part of text filter

Posted on 2014-10-12
2
99 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
ID: 40375798
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
ID: 40375916
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

914 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

22 Experts available now in Live!

Get 1:1 Help Now