Create a new dataset from a dataview

G

Guest

Hi,

I created a dataview for filtering data from a datatable, I want to create a
new dataset from this dataview. Anybody can give a simple solution?

Thanks in advance
 
K

Ken Tucker [MVP]

Hi,

The dataview has a totable method. This method is new to vb 2005.

Imports System.Data.SqlClient

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim strConn As String = _
"Server = .\SQLEXPRESS;Database = NorthWind; Integrated Security
= SSPI;"
Dim conn As New SqlConnection(strConn)
Dim da As New SqlDataAdapter("Select * from Products", conn)
Dim dt As New DataTable

da.Fill(dt)
Dim dv As New DataView(dt)
dv.RowFilter = "UnitPrice>20"

Dim dt2 As DataTable = dv.ToTable
DataGridView1.DataSource = dt2
End Sub


Ken
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top