Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

part of text filter

Posted on 2014-10-12
2
Medium Priority
?
107 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
[X]
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
2 Comments
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
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…

715 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