Solved

Getting data assigned to a variable from a rowfilter

Posted on 2006-10-19
2
214 Views
Last Modified: 2006-11-18
I am pulling back data from a SQL server and building a table with it. From there I am applying a filter to look for a specific row in that table. After this how do I assign data to a variable? If I have the IndexID I need the SwitchName.

            command = conn.CreateCommand()
            command.CommandText = "Select IndexID, SwitchNameIndex from Network_NameIndex"
            rs = command.ExecuteReader


            Dim dsData As New Data.DataSet
            Dim SwitchNameIndex As New Data.DataTable
            With SwitchNameIndex.Columns
                .Add(New DataColumn("IndexID"))
                .Add(New DataColumn("SwitchNameIndex"))
            End With
            dsData.Tables.Add(SwitchNameIndex)

            While rs.Read()

                If Not IsDBNull(rs("IndexID")) Then
                    NameIndex = rs("IndexID")
                End If
                If Not IsDBNull(rs("SwitchNameIndex")) Then
                    SwitchName = rs("SwitchNameIndex")
                End If

                Dim row As DataRow = SwitchNameIndex.NewRow()
                row(0) = NameIndex
                row(1) = SwitchName
                SwitchNameIndex.Rows.Add(row)
            End While

            Dim DataView As DataView = New DataView(SwitchNameIndex)
            DataView.RowFilter = "IndexID = '1'"
0
Comment
Question by:malich1
[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 10

Accepted Solution

by:
gangwisch earned 100 total points
ID: 17767236
you should just use:
dim dr() as datarow=SwitchNameIndex.select("indexid='1'")
your information will be contained in dr(0)("fieldname")
0
 

Author Comment

by:malich1
ID: 17767872
Excelent!
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

710 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