Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

part of text filter

Posted on 2014-10-12
2
101 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

792 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