Link to home
Start Free TrialLog in
Avatar of newbie27
newbie27Flag for United Kingdom of Great Britain and Northern Ireland

asked on

asp.net function to return dataset

Hello Experts

I am trying to store some pattern in the database table using the data from the function which returns the dataset.

I wanted to loop through all the records from this dataset and assign the value to the stringcollection variable.

Please can someone advise how I can go about looping through the rows I get from this dataset, once I get the column values I can then assign them to the string collection.

Please see the code below, hope someone may understand what I am trying to do here?

Thanks
S

Avatar of newbie27
newbie27
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

please see the code below
ds = RegistrationPersonalisedClassics.GetPatternIDAndPatternName(TemplateID)
 
 
Registration.Patterns.Add(FIRST_PATTERN_NAME_GOES_HERE + "\n" + txtPatternOne.Text)
Registration.Patterns.Add(second_PATTERN_NAME_GOES_HERE + "\n" + txtPatternTwo.Text)
Registration.Patterns.Add(third_PATTERN_NAME_GOES_HERE + "\n" + txtPatternThree.Text)
Registration.Patterns.Add(fourth_PATTERN_NAME_GOES_HERE + "\n" + txtPatternFour.Text)
Registration.Patterns.Add(fifth_PATTERN_NAME_GOES_HERE + "\n" + txtPatternFive.Text)
Registration.Patterns.Add(sixth_PATTERN_NAME_GOES_HERE + "\n" + txtPatternSix.Text)
 
 
 
 
Public Shared Function GetPatternIDAndPatternName(ByVal TemplatedID As Integer) As DataSet
 
        
        Dim dt As New Data.DataTable("Pattterns")
        Dim dr As Data.DataRow
        Dim dbConn As SqlConnection
        Dim SQL As String
        Dim dbComm As SqlCommand
        Dim dbRead As SqlDataReader
 
 
        Try
                        dbConn.Open()
            SQL = "SELECT * " & _
                  "FROM PC_Pattern " & _
                  "WHERE TemplateID=" & TemplatedID
 
            dbComm = New SqlCommand(SQL, dbConn)
            dbRead = dbComm.ExecuteReader()
 
            dt.Columns.Add(New DataColumn("PatternID", GetType(Integer)))
            dt.Columns.Add(New DataColumn("PatternName", GetType(String)))
           
            While dbRead.Read
                dr = dt.NewRow
                dr.Item("PatternID") = dbRead("PatternID")
                dr.Item("PatternName") = dbRead("PatternName")
                dt.Rows.Add(dr)
            End While
 
            ds.Tables.Add(dt)
 
            Return ds
        Catch ex As Exception
            Return Nothing
        End Try
    End Function
 
 
data
=====
patterid pattername
1	 Alice	
2	 The White Rabbit	
3	 The Queen of Hearts	
4	 The King of Hearts	
5	 The Mad Hatter	
6	 The Cheshire Cat	

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of daveamour
daveamour
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial