Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Getting data assigned to a variable from a rowfilter

Posted on 2006-10-19
2
Medium Priority
?
218 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
2 Comments
 
LVL 10

Accepted Solution

by:
gangwisch earned 400 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Screencast - Getting to Know the Pipeline
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

783 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