Solved

part of text filter

Posted on 2014-10-12
2
102 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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone 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

Title # Comments Views Activity
VB.Net - MemoryMappedFiles - Confirm receipt 2 35
VB.Net - String Manipulation Scenario 2 29
Groupbox Control ? 2 27
vb.net datagrid point 4 16
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 …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…

713 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